Hi,
I have a variable in excel vba and looking for passing the variable to MS word vba.
Any steer in the right direction is more than welcomed.
Thank you in advance
Hi,
I have a variable in excel vba and looking for passing the variable to MS word vba.
Any steer in the right direction is more than welcomed.
Thank you in advance
[vba]Sub TestPass()
Dim Wd, Doc
Set Wd = CreateObject("Word.application")
Set Doc = Wd.documents.Open("C:\AAA\Doc1.doc")
Wd.Visible = True
Wd.Application.Run "Test", "Data to pass"
Doc.Close
Set Doc = Nothing
Wd.Quit
Set Wd = Nothing
End Sub
[/vba]
In Word document
[vba]
Sub Test(MyData As String)
MsgBox MyData
End Sub
[/vba]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'