Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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!
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
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.
This worked.
- Marcus
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
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
Thanks Marcus for your help!
Best regards,
Daniel