File in Use problem

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....
 
R

Rhino

Sorry, please ignore this thread. I finally figured it out on my own.

It's funny how I often don't think of the solution until AFTER I've 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....
 
G

Gail Papke

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 poste
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 fo
someone else that finally clarifies it all in your brain...

-
Rhino

Previous Posts In This Thread:

File in Use problem
I am revisiting some VBS scripts that I wrote several years ago to generat
resumes for me (via Word macros) and would like some guidance on a couple o
errors I am getting. I will post about the two errors separately so that eac
has its own thread

My VBS script is pretty simple

======================
' Get arguments into variable
If WScript.Arguments.Count > 0 The
MsgBox "Too many arguments; expecting none.
WScript.Qui
End I

' Find path for MyDocuments folde
Set objShell = CreateObject("Shell.Application"
Set objFolder = objShell.Namespace(&H5&
strMyDocPath = objFolder.Self.Pat

' Start Word Application, open resume.doc in MyDocument
Set oWd = CreateObject("Word.Application"
oWd.Visible = Fals
Set oDoc = oWd.Documents.Open(strMyDocPath & "\rhino-resume.doc"

'Run macro named createResumeFromFile, which has no arguments, and catch it
return cod
retcde=oWd.Run("createResumeFromFile"

'Save changes to doc on closing and quit Wor
oDoc.Sav
oDoc.Clos
oWd.Qui
Set oWd = Nothin

Set objShell = Nothin

'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 Us

rhino-resume.doc is locked for editing by 'another user'

Do you want to
() Open a Read Only cop
() create a local copy and merge your changes late
() Receive notification when the original copy is availabl

[Ok] [Cancel
===============

Why am I getting this error? I am pretty sure I do not have any other use
accessing the file. This computer is a standalone machine with interne
access; it is NOT a server. I am running Windows XP SP2 and have one othe
user account on the computer but use it only VERY rarely

I suspect this problem stems from a message I got several days back wher
Word offered something or another - I cannot remember the context or messag
but it had something to do with saving a copy of the file - but I am no
sure. Also, I am not sure what to do about it if I am right. How do I mak
Word understand that it can open the file with full read-write access an
run the macro for me

Since writing the macros and the VBS scripts, I have upgraded from Word 200
to Word 2007. I am afraid I have forgotten quite a bit of what I was doing whe
I wrote the macros and scripts so I am not sure if the upgrade is a factor o
not relevant at all...

-
Rhino

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 poste
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 fo
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/tutorial...0-a5704fe31a76/biztalk-repeating-structu.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top