Whats Wrong With this

G

Guest

Dim wdApp As Word.Application
Dim wdDoc As Word.Document

Set wdApp = New Word.Application
Set wdDoc = wdApp.Documents.Open(wdfile)

With wdApp
wdDoc.Application.Run "opn_lst_eng"
End With

the only time it will work is if I get a dialog box to open it as a read only doc.
 
D

Dave Peterson

Just a guess, but maybe you already opened the document and the second/third/...
times, you have a hidden instance waiting for a response from you.

I'd make the word application visible while testing.

Set wdApp = New Word.Application
wdApp.Visible = True
Set wdDoc = wdApp.Documents.Open(wdFile)

.....

If you're running winNT (or higher), close excel and try alt-ctrl-delete. Click
on processes and see if you have a hidden instance of Word running. If yes,
kill it. And then check to see if that fixed it.

In earlier versions of windows, you may have to reboot to kill that hidden
instance of Word.
 
G

Guest

Thx I will try that but ..
I have no instance of word running..
and always the first time the code is run... word does not show (visible

but I will try it ... and see (hope)
 
D

Dave Peterson

You may want to try this:

Start notepad and copy this into that window:

dim myXL
On Error Resume Next
Set myXL = GetObject(, "Word.Application")
If Err.Number = 429 Then
msgbox "Word is not running"
else
myxl.visible = true
end If
On Error GoTo 0
Set myxl = nothing


Now save that file as "UnhideWord.Txt" (w/o the quotes).
go to windows explorer and rename this file to
unhideword.vbs

Now close every visible instance of MSWord that you have running.

And double click on that unhideword.vbs script.

If one of those word instances appears, then close that one and rerun the script
(until you kill all the hidden instances).
 

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