R
Rhino
I'm 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'll 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'm pretty sure I don't have any other user
accessing the file. This computer is a standalone machine with internet
access; it is NOT a server. I'm 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 can't remember the context or message
but it had something to do with saving a copy of the file - but I'm not
sure. Also, I'm 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've upgraded from Word 2002
to Word 2007. I'm afraid I've forgotten quite a bit of what I was doing when
I wrote the macros and scripts so I'm not sure if the upgrade is a factor or
not relevant at all....
resumes for me (via Word macros) and would like some guidance on a couple of
errors I am getting. I'll 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'm pretty sure I don't have any other user
accessing the file. This computer is a standalone machine with internet
access; it is NOT a server. I'm 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 can't remember the context or message
but it had something to do with saving a copy of the file - but I'm not
sure. Also, I'm 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've upgraded from Word 2002
to Word 2007. I'm afraid I've forgotten quite a bit of what I was doing when
I wrote the macros and scripts so I'm not sure if the upgrade is a factor or
not relevant at all....