Here is a VBA macro you can try. It doesn't search through your Workspace directories for the drawing document, so if your list of drawing names doesn't include the full file name (path and file name, with extension) it won't work yet. It just uses the simple SaveAs technique, instead of going through the true export process, so there isn't any options to specify.
Things you may have to edit before running it.
- The value of oXLFile. Change it to the full file name (with path and extension) of your source Excel file.
- The value of oSLSheet. Make sure this is the name of the sheet (or tab) in your Excel file, where the names are listed.
- The value of oCol. Make sure this is the Column in that sheet where the drawing names are listed.
- The value of o1stRow. Make sure this is set to the first row number where the names start.
- Make sure you are referencing the Microsoft Excel (version number) Object Library.
- In the VBA Editor, go to Tools tab, References..., scroll list to find this, then check the box next to it, then click OK button.
- If this process of starting Excel doesn't work for you, there are other ways to do it that may work better for you. I have a list of them if needed. This works for me, though.
Here's the code.
Sub PDF_List_Of_Drawings_From_Excel()
Dim oXLFile As String
oXLFile = "C:\Temp\Test.xlsx"
Dim oXLSheet As String
oXLSheet = "Sheet1"
Dim oCol As String
oCol = "A"
Dim oRow As Integer
o1stRow = 1
'Create New instance of the Excel application
Dim oExcel As Excel.Application
Set oExcel = New Excel.Application
oExcel.DisplayAlerts = False
oExcel.Visible = True
'Open the Workbook (file)
Dim oWB As Excel.Workbook
Set oWB = oExcel.Workbooks.Open(oXLFile)
'Get the Worksheet (Sheet or Tab)
Dim oWS As Excel.WorkSheet
Set oWS = oWB.Worksheets.Item(oXLSheet)
Dim oDrgName As String
Dim oRow As Integer
Dim oLastRowUsed As Integer
oLastRowUsed = oWS.UsedRange.Rows.Count
For oRow = o1stRow To oLastRowUsed
'Check to see if the cell is empty
If oWS.Range(oCol & oRow).Value = Nothing Or oWS.Range(oCol & oRow).Value = vbNullString Then
Next oRow
Else
oDrgName = oWS.Range(oCol & oRow).Value
End If
'Could search for this file in the Workspace directories here
'before proceeding, if needed.
Dim oDDoc As DrawingDocument
On Error GoTo Open_Failed
Set oDDoc = ThisApplication.Documents.Open(oDrgName)
Dim oPDFName As String
oPDFName = IO.Path.ChangeExtension(oDDoc.FullFileName, ".pdf")
On Error GoTo PDF_Failed
Call oDDoc.SaveAs(oPDFName, True)
Call oDDoc.Close
GoTo NextRow
Open_Failed:
Call MsgBox("Failed Open: " & oDrgName, vbOKOnly + vbCritical, " ")
GoTo NextRow
PDF_Failed:
Call MsgBox("Failed save PDF: " & oPDFName, vbOKOnly + vbCritical, " ")
GoTo NextRow
NextRow:
oRow = oRow + 1
oDrgName = oWS.Range(oCol & oRow).Value
Next oRow
oWB.Close
oExcel.Quit
End Sub
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.
If you have time, please... Vote For My IDEAS 💡and Explore My CONTRIBUTIONS
Inventor 2021 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum
Wesley Crihfield

(Not an Autodesk Employee)