![]() Set objAcroPDPage = objAcroPDDoc.AcquirePage(0) Set objAcroAVDoc = objAcroApp.GetActiveDoc IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=FalseĪctiveWorkbook.FollowHyperlink strPdfPath, NewWindow:=True ExportAsFixedFormat Type:=xlTypePDF, Filename:=strChFullName, Quality:=xlQualityStandard, _ 'Export the chart as pdf in the same folder with the excel file. StrChFullName = ActiveWorkbook.Path & "" & ActiveChart.Name 'Check if the chart caption contains a special character.įor i = LBound(arrSpecialChar) To UBound(arrSpecialChar)ĭblSpCharFound = WorksheetFunction.Find(arrSpecialChar(i), strChTitle) ![]() StrChFullName = ActiveWorkbook.Path & "" & 'For some unknown reason, even comma raises an error during saving as tiff.ĪrrSpecialChar() = Split(" / :, * ? " & Chr$(34) & " |", " ") 'An array with special characters that cannot be used for naming a file. StatusBar = "Please wait, the conversion is in progress." MsgBox "Please select a chart first and retry!", vbCritical, "Chart not selected" ![]() 'Note: the macro does NOT work with Acrobat Reader!ĭim objAcroAVDoc As New Acrobat.acroAVDoc 'C:Program FilesAdobeAcrobat xx.0Acrobatacrobat.tlb 'Alternatively you can find it Tools -> References -> Browse and check for the path 9.0 or 10.0) you have installed to your PC. 'on your Acrobat Professional version (i.e. 'Go to Tools -> References -> Adobe Acrobat xx.0 Type Library, where xx depends 'In order to use the macro you must enable the Acrobat library from VBA editor: 'The tiff file is named either with the chart title (if exists) or with the chart name. 'to crop the pdf (using the sendkeys method), save it as tiff file and then deletes the pdf. 'This macro converts a chart to pdf and then uses Adobe Professional So, what was my final solution? “Sendkeys method”! I simulated keyboard shortcuts that open the crop box, enable the remove white margins checkbox and then press the OK button – in one line this is “translated” to SendKeys (“^+TZW”). However, I couldn’t find this option programmatically. In Adobe Professional there is an option to remove the white margins automatically. In my initial solution, there was a severe malfunction: if the chart has different dimensions the crop box was either unable to cut the white margins or some part of the graph was cut.
0 Comments
Leave a Reply. |