Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I open a document in Word that is already open

Status
Not open for further replies.

StewartUK

Programmer
Feb 19, 2001
860
GB
(twice again)
Using automation, how can I open a Word document that is already open?

I looked in the VB help and found .Open(FileName, ConfirmConversions, ReadOnly). I tried this as follows:

oDoc.Open(MyDoc,.f.,.t.)

but Word still brought up the notification panel saying that the doc is locked for editing and do I want to open it Read Only!!!

Is there a way around this?

Thanks Stewart
 
Baltman,

Thanks for the reply, I hadn't come across that before. Unfortunately, it didn't work. Maybe it can't be done.

Stewart
 
How about making a copy, opening it as read-only, then deleting it upon close?
 
StewartUK

The WinAPI CopyFile() function will copy a file even though it's in use by another application.

The numeric value returned by the function determines the success or otherwise of the operation.

DECLARE INTEGER CopyFile IN kernel32 ;
[tab]STRING lpExistingFileName ,;
[tab]STRING lpNewFileName,;
[tab]INTEGER bFailIfExists

lnNo = CopyFile([C:\My Documents\test.doc];
[tab]+ CHR(0),;
[tab][C:\Temp\Temp.doc]);
[tab]+ CHR(0),;
[tab]0)

IF lnNo = 0
[tab]MESSAGEBOX([Copy unsuccessful!])
ELSE
[tab]* Word code here
ENDI

FAQ184-2483 - the answer to getting answered.​
Chris [pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top