Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
daniel_garcia_m
New Contributor II

Macro to paste Text Object in Word

Hi to everyone,

I'm trying to paste a Text Object (all object with style and font) to a Microsoft Word document. I tried a lof of things and search in community but I can't do it...


My macro is:

sub WordExport

        Set objWord = CreateObject("Word.Application")

        objWord.visible = false

        set objDoc=objWord.Documents.add

        Const wdOrientLandscape = 1

        objDoc.PageSetup.Orientation = wdOrientLandscape

        ActiveDocument.GetSheetObject("TX01").CopyTextToClipboard true

        ActiveDocument.GetSheetObject("CH01").CopyTableToClipboard true

        objWord.Selection.Paste

        objDoc.SaveAs "C:\Daniel\Pruebas\PruebaMacro2"

        objWord.Quit

       

end sub

So, I'm trying to copy objects TX01 and CH01 in word document. When I execute the macro, it doesn't work and doesn't show any error on screen...


Can anybody help me?


Thanks in advance!

1 Solution

Accepted Solutions

Re: Macro to paste Text Object in Word

This worked.

- Marcus

6 Replies
elena888
Valued Contributor

Re: Macro to paste Text Object in Word

Hi,

I tried your macro just for TX01, and it gave me the error:

ActiveX component can't create object: 'Word.Application'

for the row     Set objWord = CreateObject("Word.Application")

I don't know if this information can be usefull for you...

Elena

daniel_garcia_m
New Contributor II

Re: Macro to paste Text Object in Word

Thanks Elena for your answer.

I tried, and I can create this object. Probably, you don't have permission to allow System Acces, so change Macro security and try again.

Re: Macro to paste Text Object in Word

This worked.

- Marcus

daniel_garcia_m
New Contributor II

Re: Macro to paste Text Object in Word

Hi Marcus,

Thanks! Works like a charm!

But why? I tried to understand and I think that the problem was:

ActiveDocument.GetSheetObject("TX01").CopyTextToClipboard 'true

So, in my macro I was given a 'true' parameter that didn't need. Is this the reason?

Thanks.

Best regards,

Daniel

Re: Macro to paste Text Object in Word

Yes, CopyTextToClipboard had in opposite to CopyTableToClipboard no second parameter. You could see such things with examples in the APIGuide.qvw in your install-folder.

- Marcus

daniel_garcia_m
New Contributor II

Re: Macro to paste Text Object in Word

Thanks Marcus for your help!

Best regards,

Daniel

Community Browser