Visible:=False???

J

jan

Hi
I use macros to open a document Autotekst.doc in which I store a list of words. Whenever I want to add an item to the list, I select the item in the document I'm working on and activate a macro that should add the item to the list in Autotekst.doc. Because of varying circumstances I can never be sure whether my Autotekst.doc is at that moment opened or closed, so I use a routine to check whether it is open and respond accordingly. Everything works fine untill I add the argument Visible:=False to the statement Documents.Open Filename:="autotekst.doc" so it reads

Documents.Open Filename:="autotekst.doc", Visible:=False

The effect seems to be that the document is not opened at all, or if it is, it is also closed immediately, so that the next statement

ActiveDocument.Tables(1).Rows.Ad

When I leave out the argument Visible:=False the routine works just fine

Can anybody help me out
Thank you

Ja

results in an error.
 
P

Peter Hewett

Hi jan

When you open a document with Visible = False it never becomes the active
document. You need to do it this way:

Dim docAT as Word.Document

Set docAT = Documents.Open(Filename:="autotekst.doc", Visible:=False)
docAT.Tables(1).Rows.Add

HTH + Cheers - Peter
 

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