Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ques. on VBA in Access and Bookmarks in Word

Status
Not open for further replies.

batteam

Programmer
Sep 12, 2003
374
US
I have a Word document with Formsfields defined in it and they are also password protecded.

Can anyone help me with the VBA Code to execute in Access, behind a form, that will sent over the document password, (after I've opened it via code), so I can then send over the data to the bookmarked area in the document?

Thanks in advance for any assistance you can offer.
 
Dim woobj As Word.Application
Set woobj = CreateObject("Word.Application")
woobj.Visible = True
woobj.Documents.Open FileName, , , , Password
 
Thanks, but now I see my problem is more complicated.

I have a Word document that is procted but there are a few areas on the docuemnt that I created 'forms' from the 'forms' toolbar and set bookmarks in them. I want my code to send over (from Access 2000) data - referencing those bookmarks inside my form boxes, but I get an error that says I can't write data into them as they're protected. Yet I can open the document and type data in them manually. I need to somehow send over data to a bookmark inside a form box on a Word document that is password protected. Any help in this would be appreciated.
 
Code:
If ActiveDocument.ProtectionType <> wdNoProtection Then
    ActiveDocument.Unprotect (strPassword)
End If
 
This all works OK, but the last step is, after inserting my data into the "form field' in my document from code, I lock up the document again, to protect it from user making unauthorized changes. Problem is, what happens then is, the form field that I just inserted by data into, from VBA code, becomes locked like the rest of the document. Its as if it doesn't become a 'form field' anymore but changes to just another part of the 'protected' document. It would be nice to only have these 'form field' areas always unlocked, no matter how they get filled with data.

Thanks for any suggestions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top