Hello everyone,
i know this question have already been posted and there's a lot of info about it but im facing one problem that i hadnt solved yet and i have no idea how to solve it.
The purpose of this macro is simple: from an Excel macro, create a word object, open a file (not visible) an then export that document as pdf, and preview it.
The code im using:
I have tried with the option Visible = True, and without Active even, but there is no way to get it working.
Excel stucks in the vba editor with the loading icon from windows but i get no results.
Sometimes Word open, but also stucks without finishing loading.
Sometimes Excel tell: "Excel its waiting for another aplication to complete an OLE". i've tried disabling DDE (dinamic data exchange) but same problem persists.
Have to mention that i have only achived this with a word macro that do the same but directly with
ActiveDocument.ExportAsFixedFormat ..., but when i try to force it to print my own created object fails same way as the excel macro.
I'm starting thinking its some permission problem with my windows setup rather than the code, but need your help to debug it.
Another aspect to mention: if i try to execute a Word macro from excel, it also fails.
I have some alternatives like making a copy of the template i want to print an then let the user print o save it as pdf, but i get the same errors when working with word objects through excel macros.
Can anyone give shed some light on this? im really frustrated with something that should be easy.
thanks in advance
i know this question have already been posted and there's a lot of info about it but im facing one problem that i hadnt solved yet and i have no idea how to solve it.
The purpose of this macro is simple: from an Excel macro, create a word object, open a file (not visible) an then export that document as pdf, and preview it.
The code im using:
Code:
Sub pdf()
' Create a Word object
Set objWord = CreateObject("Word.Application")
' Create a word document object
Set objDoc = objWord.Documents.Open("C:\Users\Win\Desktop\abcd.docx")
' Make it not visible
objWord.Visible = False
' Activate the document object (just in case)
objDoc.Activate
' Export the document as pdf
objDoc.ExportAsFixedFormat OutputFilename:="C:\Users\Win\Desktop\abcd.pdf", ExportFormat:=wdExportFormatPDF, _
OpenAfterExport:=True
End Sub
I have tried with the option Visible = True, and without Active even, but there is no way to get it working.
Excel stucks in the vba editor with the loading icon from windows but i get no results.
Sometimes Word open, but also stucks without finishing loading.
Sometimes Excel tell: "Excel its waiting for another aplication to complete an OLE". i've tried disabling DDE (dinamic data exchange) but same problem persists.
Have to mention that i have only achived this with a word macro that do the same but directly with
ActiveDocument.ExportAsFixedFormat ..., but when i try to force it to print my own created object fails same way as the excel macro.
I'm starting thinking its some permission problem with my windows setup rather than the code, but need your help to debug it.
Another aspect to mention: if i try to execute a Word macro from excel, it also fails.
I have some alternatives like making a copy of the template i want to print an then let the user print o save it as pdf, but i get the same errors when working with word objects through excel macros.
Can anyone give shed some light on this? im really frustrated with something that should be easy.
thanks in advance