I am trying to call a word macro from in excel. If I ignore any variables, then it works. However, when I include any variables, it fails.
Public Sub doQuote()
'Create the quote
Dim wdApp As Object
Dim wdDoc As Object
Set wdApp = CreateObject("Word.Application")
Set wdDoc = wdApp.Documents.Open(ThisWorkbook.Path & "\NCR Form.dot")
wdApp.Visible = True
'This Works
wdApp.Run ("test")
'These Fail (Object doesnt support this property)
wdApp.Run ("test(""Str"")")
wdApp.Run "test(""Str"")"
S = "str"
wdApp.Run ("test(S)")
wdApp.Run "test(S)"
'This wont compile (.NET way of doing things)
wdApp.Run ("test", "Str")
Set wdApp = Nothing
Set wdDoc = Nothing
End Sub
Basically I've tried everything I can find and nothing seems to work as wanted. Any help would be awesome.
Thanks
Public Sub doQuote()
'Create the quote
Dim wdApp As Object
Dim wdDoc As Object
Set wdApp = CreateObject("Word.Application")
Set wdDoc = wdApp.Documents.Open(ThisWorkbook.Path & "\NCR Form.dot")
wdApp.Visible = True
'This Works
wdApp.Run ("test")
'These Fail (Object doesnt support this property)
wdApp.Run ("test(""Str"")")
wdApp.Run "test(""Str"")"
S = "str"
wdApp.Run ("test(S)")
wdApp.Run "test(S)"
'This wont compile (.NET way of doing things)
wdApp.Run ("test", "Str")
Set wdApp = Nothing
Set wdDoc = Nothing
End Sub
Basically I've tried everything I can find and nothing seems to work as wanted. Any help would be awesome.
Thanks
Last edited: