2

The following code was working but something happened and now it hangs on

Set DocVersions=Activeworkbook.DocumentLibraryVersions

I have even tried simple subs that with only the Dim and Set lines and it just hangs. I have also tried removing the Reference to the Microsoft Office 16.0 Object Library.

Not even sure what else to try

Sub getVersions()

Dim DocVersions As DocumentLibraryVersions
Dim DVersion As DocumentLibraryVersion
Dim clipobj As New DataObject
Dim clipdata As String
Dim i As Integer

Set DocVersions = ActiveWorkbook.DocumentLibraryVersions
i = DocVersions.Count
For Each DVersion In DocVersions
i = i - 1
Debug.Print i
clipdata = clipdata & DVersion.Index & vbTab & _
DVersion.Modified & vbTab & _
DVersion.ModifiedBy & vbTab & _
DVersion.Comments & vbCr

    Debug.Print "index " & DVersion.Index
    Debug.Print "comment " & DVersion.Comments
    'Debug.Print "creator " & DVersion.Creator
    Debug.Print "Modified Date " & DVersion.Modified
    Debug.Print "Modified By " & DVersion.ModifiedBy
   ' Debug.Print "application " & DVersion.Application

Next

Set DocVersions = Nothing
Set DVersion = Nothing


clipobj.SetText clipdata
clipobj.PutInClipboard

MsgBox "Version Info Placed on Clipboard"

End Sub
Cindy Meister
  • 25,071
  • 21
  • 34
  • 43
Michael
  • 21
  • 1
  • Are you trying this in Excel? What is the error that you are getting? – Vityata Feb 14 '19 at 14:24
  • It looks like this code is designed to work with a *non-Microsoft* library - `DocumentLibraryVersion`. Either the reference to this library has been lost (Tools/References) or the library isn't installed on the machine where the code is being run. Since you say you've checked the reference, make sure this library is installed and that the reference is pointing to the install location. – Cindy Meister Feb 14 '19 at 14:56
  • On re-reading... Is this supposed to look something up in SharePoint? Is it possible there's no answer coming back from SharePoint, which is why it seems to hang? – Cindy Meister Feb 14 '19 at 14:58
  • the library is installed. I have turned the reference to Microsoft Office Objects off and back on. When it is off the DocumentLibraryVersions is not available and when I turn it back on it is so I assume it is "installed." The file is on Sharepoint and Sharepoint is working fine outside of this code. – Michael Feb 15 '19 at 12:59
  • Just read Vityata's question.... No error it just hangs and i have to kill off excel to get out. – Michael Feb 15 '19 at 13:25
  • Couldn't make it work. Following to see if there's an alternative – Ricardo Diaz Jul 07 '19 at 22:26

1 Answers1

0

I've had exactly the same problem when the following was hanging up the process: Set DocVersions=Activeworkbook.DocumentLibraryVersions

After checking out the file for the first time and checking it in again, then the code continues as expected and does no longer hang at this point.

Thomas
  • 1
  • 1
  • This solution does not work for me - on a Library with no checkout/checkin functionality enabled. Every time I (or my colleagues) call Activeworkbook.DocumentLibraryVersions (or any of its child methods) Excel just hangs with the blue spinning wheel to indicate it is 'doing something'. – RobBaker May 24 '23 at 14:41