Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

save xlsx as pdf

mblaptok
Contributor

save xlsx as pdf

mblaptok
Contributor
Contributor

Is it possible to save xlsx as pdf from Inventor 2019? (VBA?)

 

To make it clear, I exported some parameters to xlsx file then i save it, and now i'd like to save it as pdf directly from Inventor (maybe i want too much :slightly_smiling_face: )

 

SyntaxEditor Code Snippet

GoExcel.CellValue("filename.xlsx", "Sheet1", "A2")= "whatever"

SyntaxEditor Code Snippet

GoExcel.Save

 

 

0 Likes
Reply
280 Views
1 Reply
Reply (1)

JamieVJohnson2
Collaborator
Collaborator

GoExcel automates portions of the Excel Interop API.  with the Excel object and the ws (worksheet) object this is the complete Excel Interop method (vb.net) to print/save PDF from Excel using its built in PDF driver.

 Try
                ws.PageSetup.PrintArea = rngTable.Address
            Catch ex As Exception
                MsgBox("Error setting print area to table size.")
            End Try
            Try
                ExcelApp.PrintCommunication = False
            Catch ex As Exception

            End Try
            Try
                ws.PageSetup.Zoom = False
            Catch ex As Exception
                MsgBox("Error setting page setup zoom mode to false.")
            End Try
            Try
                ws.PageSetup.FitToPagesWide = 1
            Catch ex As Exception
                MsgBox("Error setting page setup fit to pages wide to 1.")
            End Try
            Try
                ws.PageSetup.FitToPagesTall = 0
            Catch ex As Exception
                MsgBox("Error setting page setup fit to pages tall to auto (0).")
            End Try
            Try
                ExcelApp.PrintCommunication = True
            Catch ex As Exception

            End Try
            'save file
            If Not String.IsNullOrWhiteSpace(DrawingListPath) Then
                If System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(DrawingListPath)) = False Then
                    System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(DrawingListPath))
                End If
                If WorkFile.Exists Then
                    WorkFile.Delete()
                    WorkFile.Refresh()
                End If
                wb.SaveAs(DrawingListPath, , , , , , , Excel.XlSaveConflictResolution.xlUserResolution)
                'print table to pdf
                ws.ExportAsFixedFormat(Excel.XlFixedFormatType.xlTypePDF, WorkFile.FullName, Excel.XlFixedFormatQuality.xlQualityStandard, True, False, , , False)
                wb.Close()
                           End If

 WorkFile is an instance of the class System.IO.FileInfo, and since there are many ways Excel can kick back errors I have many try catch blocks.

 

jvj
0 Likes