PC Review


Reply
Thread Tools Rate Thread

Determine when Word document opens successfully from Excel VBA

 
 
Alan
Guest
Posts: n/a
 
      14th Apr 2009
Is there a way in Excel VBA to determine when a Word document has
been opened successfully? Or better yet, when the Word application
will be free to open another document?

In a loop in Excel VBA I open up Word documents one-by-one, the
Word document automatically does some things (like update links and
print), and meanwhile Excel checks to see if Word is done (results in
a PDF file), then moves to the next document.

After several documents are successfully processed, my VBA code in
Excel fails on trying to open up the next Word document:

Dim WordDoc as Word.Document
. . .
Set WordDoc = WordApp.Documents.Open(sWordDocPath & sWordName)

and returns the error

"Microsoft Office Excel is waiting for another application to complete
an OLE action." Things get hung up from there, and I have to use
TaskManager to kill the WinWord process.

I tried throwing in some Sleep commands, to give things time to
finish, but that did not seem to improve anything.

I tried checking the value of WordDoc after the .Open statement,
but it never reaches it. It gets hung on the .Open statement.

I am not sure how to diagnose things from here.

Thanks in advance for your help! Alan





 
Reply With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      14th Apr 2009
Try using the timer funciton in VBA
--
If this post helps click Yes
---------------
Jacob Skaria


"Alan" wrote:

> Is there a way in Excel VBA to determine when a Word document has
> been opened successfully? Or better yet, when the Word application
> will be free to open another document?
>
> In a loop in Excel VBA I open up Word documents one-by-one, the
> Word document automatically does some things (like update links and
> print), and meanwhile Excel checks to see if Word is done (results in
> a PDF file), then moves to the next document.
>
> After several documents are successfully processed, my VBA code in
> Excel fails on trying to open up the next Word document:
>
> Dim WordDoc as Word.Document
> . . .
> Set WordDoc = WordApp.Documents.Open(sWordDocPath & sWordName)
>
> and returns the error
>
> "Microsoft Office Excel is waiting for another application to complete
> an OLE action." Things get hung up from there, and I have to use
> TaskManager to kill the WinWord process.
>
> I tried throwing in some Sleep commands, to give things time to
> finish, but that did not seem to improve anything.
>
> I tried checking the value of WordDoc after the .Open statement,
> but it never reaches it. It gets hung on the .Open statement.
>
> I am not sure how to diagnose things from here.
>
> Thanks in advance for your help! Alan
>
>
>
>
>
>

 
Reply With Quote
 
Alan
Guest
Posts: n/a
 
      14th Apr 2009
Originally, I was starting up the Word application, processing all
the Word documents, then quitting the Word application. When I
changed this to start the Word app, process one document, quit the
Word app, then repeat, it worked.

Also, I used Sleep() vice Application.Waittime.


Alan


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
The document was saved successfully, but Excel cannot re-open it b Joseph George Williams (Balasarius) Microsoft Excel Crashes 0 31st Mar 2010 03:55 PM
Word 2003 document opens slowly, analyzing document Ansie Microsoft Word Document Management 1 22nd Feb 2010 02:38 PM
Shift key highlights all word document text, opens all word docume =?Utf-8?B?R2Vl?= Microsoft Word Document Management 1 1st Feb 2007 12:55 AM
help creating a macro in excel that opens a specific word document =?Utf-8?B?UHJvaG9jaw==?= Microsoft Excel Misc 3 30th Mar 2006 04:58 PM
same document opens on word every time word page opens =?Utf-8?B?RnJ1c3RyYXRlZCBXb3JkIHVzZXI=?= Microsoft Word Document Management 1 25th Apr 2005 04:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:49 AM.