Word 2003 VBScript - Master & Child Documents

dickohead

Registered User.
Local time
Today, 14:44
Joined
Dec 7, 2005
Messages
42
Hi all,

I currently have quite a few documents that incorporate child documents into their make up.

I also have quite a few documents that use input boxes to prompt users for data input. (InputBox(Prompt:="Your name is?").

I now have a document that is a combination of the two but have run into an issue.

When I load up the word document I have a module called AutoOpen() with the following code:
Code:
Sub AutoOpen()
[B]ActiveDocument.Subdocuments.Expanded = True[/B]
'Asks if the user they wish to prompted for input or not.
On Error Resume Next
vAnswer = MsgBox(Prompt:="Do you wish to be prompted for form data?", Buttons:=vbYesNo)
ActiveDocument.Unprotect
If vAnswer = 6 Then
    ActiveDocument.Protect wdAllowOnlyFormFields
    mRefNo
    mFirstName
    mLastName
    mAddress
    mSubStateCode
    MsgBox ("All Done.")
Else
    ActiveDocument.Protect wdAllowOnlyFormFields
    Exit Sub
End If

End Sub

The above simply calls up each one of my questions, and stores the responses in the appropriate form fields in my document --> This works great.

But now I am trying to run:
Code:
ActiveDocument.Subdocuments.Expanded = True
Before _any_ of the user prompt boxes are run - but this does not happen unless I force the document to re-run AutoOpen() after the document has loaded.

How do I ensure that:
Code:
ActiveDocument.Subdocuments.Expanded = True
Is run before _anything_ else in my document?

Let me know if I have been unclear...
 

Users who are viewing this thread

Back
Top Bottom