Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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.
Maybe this one is helpful to get the logic and syntax right: Re: Macro to paste Text Object in Word
- Marcus
Can you please provide me a exact code on mine.
Regards,
Ranjith