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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing a variable form one document o another document

Status
Not open for further replies.

nochoice

Programmer
Jun 17, 2003
72
CA
Here's my code:

'=====================================
Private Sub add_doc_Click()

Documents.Open (net_director + "Add Document.doc")

ActiveDocument.Variables.Add Name:="net_dir", Value:=net_director

MsgBox (ActiveDocument.Name)

End Sub
'==========================================


Note: net_director is a public function and it is the value of the network directory where these files are stored.

What I want to do is pass the value of net_director to add document.doc. Am I way off in my code?

Add document.doc has macros, I haven't declared net_dir at all in add document.doc, however, there is a button and when I click the button this is my code

'===========================
MsgBox (net_dir)
'===========================


Note: Msgbox (net_dir) is always blank.

Thanks for you help.
 
Hi,

If net_director is returning blank, the problem is with that function.

I simulated net_director by returning "C:\" and using a document that I have in my root directory and it worked.

Skip,
Skip@TheOfficeExperts.com
 
Here is the function code:

'====================
Public Function net_director() As String
net_director = "c:\"
End Function
'====================


I know this isn't returning blank because it opens the document.

However, I now get an error 5903 Variable name already exists. This makes a bit of sense.

Would this be easier if I declared the variable in add documents.doc? if so, how would I pass the variable?

Thanks
 
I decided to start from scratch and make things simple

Note: Both MsgBoxes are blank.

Here is my code:

'== open add documents.doc
Private Sub CommandButton1_Click()

Documents.Open ("C:\Add Document.doc")

ActiveDocument.Variables.Add Name:="net_dir", Value:="12"

MsgBox (net_dir)

End Sub
'==========================



'==== button code in add documents.doc
Private Sub CommandButton1_Click()
MsgBox (net_dir)
End Sub

'==========================

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top