![]() |
print embedded multiple page OLE objects
Hi all,
We have a multiple page/worksheet excel file that uses a macro to print all of the worksheets to a single pdf file. this works fine btw :) the problem now is that i want to extend the excel file to include some OLE word/pdf documents that can be printed using the same button. these OLD objects will be multiple pages in length. macro so far: ################################################## Sub Print_PDF() Application.ActivePrinter = "CutePDF Writer on CPW2:" Sheets("DATA ENTRY & PRESENTATION SHEET").Select Sheets("BRIEFING").Select False Sheets("METHOD").Select False Sheets("SHEET1").Select False Sheets("RISK MATRIX").Select False Sheets("BLANK RISK").Select False Sheets("RISKS DATABASE").Select False ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True End Sub ################################################## now, i found this code: ################################################## Dim wksWithWordDocs As Worksheet Dim wordObject As OLEObject Dim wordDocument As Word.Document Set wksWithWordDocs = ThisWorkbook.Worksheets("Sheet1") For Each wordObject In wksWithWordDocs.OLEObjects wordObject.Activate Set wordDocument = wordObject.Object wordDocument.PrintOut wordDocument.Close Next wordObject ################################################## it apparently will print out old objects but it doesnt work for me, even if i set up a Reference to Microsoft Word 11.0 Object library in the VB editor. i get a 'run-time error 1004 - unable to find object propert of the OLEObject class' with this line: Set wordDocument = wordObject.Object any ideas? thanks in advance peeps :) |
print embedded multiple page OLE objects
as another approach, allowing then system to open up and print the (prevously
ole embedded) documents would also work, if this is an easier option. "Liam T" wrote: Hi all, We have a multiple page/worksheet excel file that uses a macro to print all of the worksheets to a single pdf file. this works fine btw :) the problem now is that i want to extend the excel file to include some OLE word/pdf documents that can be printed using the same button. these OLD objects will be multiple pages in length. macro so far: ################################################## Sub Print_PDF() Application.ActivePrinter = "CutePDF Writer on CPW2:" Sheets("DATA ENTRY & PRESENTATION SHEET").Select Sheets("BRIEFING").Select False Sheets("METHOD").Select False Sheets("SHEET1").Select False Sheets("RISK MATRIX").Select False Sheets("BLANK RISK").Select False Sheets("RISKS DATABASE").Select False ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True End Sub ################################################## now, i found this code: ################################################## Dim wksWithWordDocs As Worksheet Dim wordObject As OLEObject Dim wordDocument As Word.Document Set wksWithWordDocs = ThisWorkbook.Worksheets("Sheet1") For Each wordObject In wksWithWordDocs.OLEObjects wordObject.Activate Set wordDocument = wordObject.Object wordDocument.PrintOut wordDocument.Close Next wordObject ################################################## it apparently will print out old objects but it doesnt work for me, even if i set up a Reference to Microsoft Word 11.0 Object library in the VB editor. i get a 'run-time error 1004 - unable to find object propert of the OLEObject class' with this line: Set wordDocument = wordObject.Object any ideas? thanks in advance peeps :) |
All times are GMT +1. The time now is 05:37 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com