Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Open Word file with Excel VBA

Hi,

I want to open a Word file using an Excel macro, but it doesn't work as I
want.
I get the message: This file is locked for editing by another user....."
It must have something to do with the macro, because the file is not locked
or already open.
How can I avoid this message?

Dim wdApp As Object
Dim wdDoc As Object
Set wdApp = CreateObject("Word.application")
wdApp.Visible = True
Set wdDoc = wdApp.Documents.Open _
(Filename:="C:\Documents and Settings\XXX\Desktop\test.doc")

Regards
Kaj Pedersen


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default Open Word file with Excel VBA

The code worked for me.I think you have opened the file
programmatically earlier and not closed.It will not be visible.
Try to close the file containg macro .reopen the file and try once.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 279
Default Open Word file with Excel VBA

In message
s.com of Sun, 25 Sep 2011 22:50:12 in microsoft.public.excel.programmin
g, Javed writes
The code worked for me.I think you have opened the file
programmatically earlier and not closed.It will not be visible.
Try to close the file containg macro .reopen the file and try once.


I roughly agree. The OP might reboot the system to start with a known
position and see if the problem disappears.

There seems to be a lack of facilities in Office to tidy up
automatically after Office opens another application.
One can easily get orphan applications which are hidden.
e.g. With code (untested) like:
CreateObject("Word.application").Documents.Open(Fi lename:=foo)

I expect there is a hidden instance of Word locking "C:\Documents and
Settings\XXX\Desktop\test.doc". On my Vista system running Office 2003,
I would open the Task Manager, after right-clicking on an empty part of
the Taskbar, and looking for WINWORD.EXE in the processes tab. "End
Process" with confirmation should zap the problem.

The OP does not say which version of Office or operating system shows
the problem.
--
Walter Briscoe
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open new Word file via Excel Lupe Excel Programming 3 September 5th 07 06:26 AM
open word from excel...file does not exist error tbaam Excel Programming 9 January 16th 07 03:34 PM
Using an Excel macro to open a Word File lhyer Excel Programming 4 July 18th 05 09:28 PM
Open One Word File from Excel Stratuser Excel Programming 6 January 27th 04 06:37 PM
Graph Excel Selection, Open Word File, Embed Graph Into Word Steve Excel Programming 0 November 17th 03 05:35 PM


All times are GMT +1. The time now is 09:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"