Home
TeamSite
Help with VBA macro to open worksite document and wait for it to open
andyfarrell
Hi all, grateful for any help please. I have limited VBA knowledge and have a situation where a macro in Word 2010 is used to open a document from worksite using code as pasted below. This works really well but the problem is there is other VBA code that is running straight afterwards before the document has actually opened.
Is there a way to wait for the document requested by the shellexecute to open before continuing to process further code?
I am not keen to use wait and hoping there is a way to use a loop to check if the document is open yet and proceed when it has?
Thank you!
Dim objShell
Dim iwlurl As String
Set objShell = CreateObject( "Shell.Application ")
iwlurl = "iwl:dms= " & imdoc.Database.Session.Alias() & " &lib= " & imdoc.Database.Name & " &num= " & imdoc.Number & " &ver= " & imdoc.Version & " &command=opencmd "
Call objShell.ShellExecute(iwlurl, " ", " ", " ", 1)
Set objShell = Nothing
Find more posts tagged with
Comments
guido1
Hi Andy
Using the IWL link in the way described in your code snippet sounds very much like a hack. It'll open the document but effectively it is an out-of-process call, so your local VBA code will just move on to the next task as you describe.
The recommended way would be to reference the iManage Extensibility COM library (iManExt.dll) and then create a new instance of OpenCmd.
OpenCmd is capable of silently downloading a document in integrated mode (i.e. to your C:\NrPortbl folder) and returning you a path to the downloaded document.
From there you can just use the regular Word object model to open the document in the Word application itself.
The OpenCmd is all documented in the SDK documentation, if you've purchased that.
andyfarrell
Hi, thanks for info last year! We solvedthe problem with a loop that waited for the document to be open before continuing ... but its the time of year when we look at our processes again and I am really keen to do a better job than the "hack" we used before. We do own the SDK and I have downloaded and installed but cant find any reference to OpenCMD
The only documents that came with the SDK are :
WorkSite Desktop Client Customization Guide (9.0, English).pdf
Microsoft Office Integration for WorkSite SDK Release Notes (9.0, English).pdf
Microsoft Office Integration for WorkSite Developers Guide (9.0, English).pdf
iManVBALib_Excel.bas
iManVBALib_Word.bas
Also looked through and searched vbalib and cannto find OpenCMD is there some other SDK documentation I am missing?
Sorry am still learning! any help much appreciated