Inputting text to word document

H

hlam

Is there a way that I can input text via VBA to text form fields that are
write protected thru Access 2000 and how?

Here are the codes I used but not working:

Dim wd As Object
Set wd = CreateObject("word.application")
wd.Documents.Open "F:\testing"
wd.Parent.Visible = True
wd.Activate
wd.ActiveDocument.Bookmarks("FirstName").Select
Selection.TypeText Text:="Hello" ** error message

** error message: Method 'Selection' of object '_Global' failed
 
B

Brendan Reynolds

You might get a more definitive answer in a Word group, but it seems to me
that if you could write to something that was write protected, that would
mean that the write-protection mechanism was broken, no? My guess is that
you need to be looking for a way to turn protection off (and back on again
afterwards) but as I said, you may get a better answer in a Word group.
While you may be executing this code from Access, the solution, if there is
one, will probably be found in the Word object model.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
G

George Nicholson

While you may be executing this code from Access, the solution, if there
is one, will probably be found in the Word object model.
Yep.

Neither "Selection" or "TypeText" are in the Access object model, so an
error on that line is a given.
I suspect that particular error would be resolved by something like:
wd.Selection.TypeText Text:="Hello"
but I say that with very little knowledge of Word's object model, so buyer
beware.
 
B

Brendan Reynolds

Doh! Well spotted, George!

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 

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