How to check ActiveDocument

T

Thejan Mendis

Hi,

I have created a macro which will insert some text to the bookmaks through
my User form that I created in a templete (.dot).

My problem is every time I run the templete, it will create new document and
If I might need to use anather word document and come back to my main user
form it gave me ERROR 5941.

HOW DO I TELL MY MACRO THAT IT SHOULD ONLY REFER THE DOCUMENT THAT CONTAIN
THE BOOKMARKS



THEJAN
 
C

Cindy M -WordMVP-

Hi Thejan,
I have created a macro which will insert some text to the bookmaks through
my User form that I created in a templete (.dot).

My problem is every time I run the templete, it will create new document and
If I might need to use anather word document and come back to my main user
form it gave me ERROR 5941.

HOW DO I TELL MY MACRO THAT IT SHOULD ONLY REFER THE DOCUMENT THAT CONTAIN
THE BOOKMARKS
Basically, it's best to set an object variable that refers to one, specific
document. If you had a macro that created a Word document, that you then
wanted to manipulate, you could:
Dim doc as Word.Document
Set doc = Documents.Add "Template path and name, here"
doc.Bookmarks("name").Range.Text = "etc."

Setting the object variable (doc) can be done in various ways, depending on
the exact situation. Unfortunately, I don't understand enough about how your
template is supposed to work to tell you "exactly" what you need to do...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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