- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a list of drawing numbers which I have placed in an excel with their location intact. I want to convert all of them into PDFs through VBA excel macro.
Currently I am using the below code but it isn't working for me:
Sub ConvertToPDF()
Dim oWkbk As Workbook
Set oWkbk = ThisWorkbook
Dim oSheet As Worksheet
Set oSheet = oWkbk.ActiveSheet
sFilepathRange = "O2:O50"
Dim oAcadApp As Object
Dim oAcadDwg As AcadDocument
Set oAcadApp = CreateObject("Autocad.Application")
oAcadApp.Visible = True
Dim sFilePath As String
'oAcadApp.Documents.Close
For Each oCell In oSheet.Range(sFilepathRange)
If oCell <> "\.dwg" Then
Set oAcadDwg = oAcadApp.Documents.Open(oCell, True)
'oAcadDwg.ActiveLayout.UseStandardScale = True
'oAcadDwg.ActiveLayout.StandardScale = acScaleToFit
'oAcadDwg.ActiveLayout.PlotRotation = PlotRotation
'oAcadDwg.ActiveLayout.StyleSheet = "monochrome.ctb"
'oAcadDwg.ActiveLayout.ConfigName = "PDF-XChange 4.0 Lite"
'oAcadDwg.ActiveLayout.CanonicalMediaName = "Letter"
'oAcadDwg.ActiveLayout.PlotType = acExtents
'oAcadDwg.Plot.PlotToDevice
End If
oAcadApp.Documents.Close
Next
oAcadApp.Quit
Set oAcadApp = Nothing
MsgBox "Converted to PDF"
End Sub
Please help me with the correct code.
Regards,
Mohammed Shuaib
Solved! Go to Solution.