Tuesday 15 January 2013

excel vba - How to save a sheet array to PDF with a specific sheet order -


I have a workbook with multiple sheets which I want to select and change a single pdf file.

I have written the following code that works fine and creates a file:

  sub Print_Project_Report_To_PDF file as string FilePathandName String MyDate = Format (DateSerial (year (now) , Month (now) - 1, 1), "mm mm") MyPath = ThisWorkbook.Path & amp; "\" Mayfile = "Project Progress Report -" & amp; Mind & amp; ".pdf" file path and name = MYPAT & amp; MyFile ThisWorkbook.Sheets (Array ("PR_COVER_PAGE", "PR_SOWMARY", "PR_PROJECT_DETAILS", "PR_INTERNAL RESOURCES", "PR_TIME", "PR_REVENUE_FORECAST_SUMMARY", "PR_ORIGINAL_REVENUE_FORECAST", "PR_ACTUAL_REVENUE_FORECAST", "PR_COSTS", "PR_ISSUES", " Monthly Financial Report "," PG SC_COVER_LETTER "," PG SC_CLAIM_SUMMARY "," PG SC_TRADE "," PG SC_HYDRAULICS "," PG SC_MECHANICAL "," PG SC_MEDICAL_GASES "," PG SC_ELECTRICAL "," PG-SC_VERIATION "," PG -PC-MH_ELECTRICAL "," PG-MH_ELECTRICAL "," PG-MH_ELECTRICAL "," PG-MH_COVER_LETTER "," PG- MH_CLAIM_SUMMARY "," PG- MH_TRADE "," PG- MH_Hydrix "," PG- MH_MECHANICAL "," PG- MH_VARIATION "," PG-MH_MONTHLY_CASHFLOW "," CLIENT_COVER ", _" CLIENT_SUMMARY "," CLIENT_ISSUES ")). Select ActiveSheet.ExportAsFixedFormat type: = xlTypePDF, file name: = FilePathandName, _Quality: = xlQualityStandard, IncludeDocProperties: = True, _IgnorePrintAreas: = false, OpenAfterPublish:. Select the TrueWorldbook.Sheets ("Dashboard") End Sub   

The problem is that PDF file lay is not created with sheets, which I have specified in the array. They are in order that they appear in the workbook (left to right). This is correctly included only sheets but I do not want it in the order I want.

I do not want to change the order of the sheet in the workbook because neither it is setup in a specific, progressive way.

Can anyone help with my code which will be able to be specific with the order of the sheet when the document is published?

Any help would be greatly appreciated.

I agree with Siddhartha / in the first thought / comment below the question. However, when I print complex power point presentation, in the same situation

I run the software on the first step and set the 'stop printing' option . You can send each worksheet separately to that software (the way you print the worksheet), which will be stacked in the list in the right order at the beginning of the individual documents. Using special feature, you can match them in a document and print it. This is a very useful and quite reliable solution.

No comments:

Post a Comment