Prev: Nested table question (W2003)
Next: Importing/parsing data from an external file in Word 2007 Macros
From: Gail on 22 Mar 2010 12:48 How did you eliminate the "File in use" message box? Rhino wrote: Sorry, please ignore this thread. I finally figured it out on my own. 23-Feb-10 Sorry, please ignore this thread. I finally figured it out on my own. it is funny how I often do not think of the solution until AFTER I have posted the question to a newsgroup or forum, even after giving it a lot of thought. It must be something to do with the process of describing the problem for someone else that finally clarifies it all in your brain.... -- Rhino Previous Posts In This Thread: On Tuesday, February 23, 2010 6:24 PM Rhino wrote: File in Use problem I am revisiting some VBS scripts that I wrote several years ago to generate resumes for me (via Word macros) and would like some guidance on a couple of errors I am getting. I will post about the two errors separately so that each has its own thread. My VBS script is pretty simple: ======================= ' Get arguments into variables If WScript.Arguments.Count > 0 Then MsgBox "Too many arguments; expecting none." WScript.Quit End If ' Find path for MyDocuments folder Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace(&H5&) strMyDocPath = objFolder.Self.Path ' Start Word Application, open resume.doc in MyDocuments Set oWd = CreateObject("Word.Application") oWd.Visible = False Set oDoc = oWd.Documents.Open(strMyDocPath & "\rhino-resume.doc") 'Run macro named createResumeFromFile, which has no arguments, and catch its return code retcde=oWd.Run("createResumeFromFile") 'Save changes to doc on closing and quit Word oDoc.Save oDoc.Close oWd.Quit Set oWd = Nothing Set objShell = Nothing 'Exit the script with the value of the return code from the macro/function. That will be zero from a successful execution or 1 otherwise. wscript.quit(retcde) ======================= When I execute this code, I get a message dialog saying: ============== File In Use rhino-resume.doc is locked for editing by 'another user'. Do you want to: () Open a Read Only copy () create a local copy and merge your changes later () Receive notification when the original copy is available [Ok] [Cancel] ================ Why am I getting this error? I am pretty sure I do not have any other user accessing the file. This computer is a standalone machine with internet access; it is NOT a server. I am running Windows XP SP2 and have one other user account on the computer but use it only VERY rarely. I suspect this problem stems from a message I got several days back where Word offered something or another - I cannot remember the context or message but it had something to do with saving a copy of the file - but I am not sure. Also, I am not sure what to do about it if I am right. How do I make Word understand that it can open the file with full read-write access and run the macro for me? Since writing the macros and the VBS scripts, I have upgraded from Word 2002 to Word 2007. I am afraid I have forgotten quite a bit of what I was doing when I wrote the macros and scripts so I am not sure if the upgrade is a factor or not relevant at all.... -- Rhino On Tuesday, February 23, 2010 6:48 PM Rhino wrote: Sorry, please ignore this thread. I finally figured it out on my own. Sorry, please ignore this thread. I finally figured it out on my own. it is funny how I often do not think of the solution until AFTER I have posted the question to a newsgroup or forum, even after giving it a lot of thought. It must be something to do with the process of describing the problem for someone else that finally clarifies it all in your brain.... -- Rhino Submitted via EggHeadCafe - Software Developer Portal of Choice BizTalk Repeating Structures Table Looping and Table Extract http://www.eggheadcafe.com/tutorials/aspnet/73bf7539-4c13-43a5-a580-a5704fe31a76/biztalk-repeating-structu.aspx |