Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

While running my Marco using VB, it throws an error in path line.

Hi All,

I have created macro for one button in excel to generate a template which is stored in word document.

As highlighted in red color, I am getting error on the path line:

Can anyone please help me on this to fix

Private Sub CommandButton1_Click()

Dim wordapp As Object

Dim worddoc As Object

Set wordapp = CreateObject("word.application")

Set worddoc = wordapp.Documents.Open("Desktop\Macro_file")

h = wordapp.ActiveDocument.Content.Text

a = InStr(1, h, "Sample Template 2")

b = Left(h, a - 1)

Worksheets("sheet2").Range("a1").Value = b

TextBox1.Text = b

Worksheets("sheet2").Range("a1").Copy

Set wordapp = Nothing

Set worddoc = Nothing

End Sub

Regards,

Ranjith

3 Replies
Gysbert_Wassenaar

In Qlikview you need to write a macro in vbscript, not Visual Basic or Visual Basic for Applications.

And you need to make sure that the security settings in the module allow the creation of objects using the CreateObject function. You'll probably have to set Requested Module Security to System Access and Current Local Security to Allow System Access.


talk is cheap, supply exceeds demand
marcus_sommer

Maybe this one is helpful to get the logic and syntax right: Re: Macro to paste Text Object in Word

- Marcus

Not applicable
Author

Can you please provide me a exact code on mine.

Regards,

Ranjith