Message 1 of 10
Vba for saving PDF file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Folks, first off I am not a code guy so please go easy😂
With my small knowlegde I assembled the below code, I got parts from other codes and with my little knowledge I coud get till here i.e. the problem starts on the following line. = > Doc.PLOT.PlotToFile (pdffile)
at this point a window pops-up to indicate a place and the name of the file, so I want to include in my code the lines for indicate the path and the file name without the system opening this window. Do you know how to do that?
Sub PrintTOPdf()
Dim App As Object
Dim Doc As Object
Dim pdffile As String
Dim result As String
Dim cadfile As String
Dim papersize As String
Dim backPlot As Integer
Dim FldrPicker As FileDialog
Dim Caminho As String
Dim ExtDwg As String
Dim ExtPdf As String
Set FldrPicker = Application.FileDialog(msoFileDialogFolderPicker)
With FldrPicker
.Title = "Selecione a pasta para imprimir os arquivos"
.AllowMultiSelect = False
If .Show <> -1 Then Exit Sub
Caminho = .SelectedItems(1) & "\"
End With
ExtDwg = "*.dwg"
ExtPdf = "*.pdf"
cadfile = Dir(Caminho & ExtDwg, vbNormal)
pdffile = Len(cadfile)
pdffile = Left(cadfile, pdffile - 4)
' pdffile = pdffile & ".pdf"
pdffile = Caminho & pdffile & ".pdf"
Set App = CreateObject("autoCad.Application")
App.Visible = False
Set Doc = App.Documents.Open(Caminho & cadfile)
Doc.ActiveLayout.ConfigName = "PDF-XChange Standard.pc3"
backPlot = Doc.GetVariable("BACKGROUNDPLOT")
Doc.SetVariable "BACKGROUNDPLOT", 0
Doc.SetVariable "filedia", 0
If cbtfile <> "" Then
Doc.ActiveLayout.StyleSheet = cbtfile
Else
Doc.ActiveLayout.StyleSheet = "monochrome.ctb"
End If
Doc.ActiveLayout.CanonicalMediaName = "A3"
Doc.PLOT.PlotToFile (pdffile)
Doc.SetVariable "BACKGROUNDPLOT", backPlot
Doc.Close False
App.Quit
MsgBox "All printed"
End Sub
Thank you very much for any help.
Jonny