0

i have a macro to save multiple files with different names, and dont want to click on save each time the save as dialog box pops up. Ive tried with Application.DisplayAlerts = False but it doesnt work. Any ideas?


'GED
Windows("boprov.xlsm").Activate
Worksheets("Hoja4").Select
Workbooks(ActiveSheet.Range("G53").Value).Activate
Worksheets("Bonos en Cartera").Select
pdfName = ActiveSheet.Range("AA2")
    ChDir "C:\Users\GALILEO\Documents\CarterasPDF" 'This is where youo set a defult file path.
    fileSaveName = Application.GetSaveAsFilename(pdfName, _
    fileFilter:="PDF Files (*.pdf), *.pdf")
    If fileSaveName <> False Then
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        fileSaveName _
        , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
        :=False, OpenAfterPublish:=True
    End If

The macro consist on many of these chunks of code for each workbook, and each time it finishes saving one, a dialog box asking me to click on save will show up. Thank you for your help!

braX
  • 11,506
  • 5
  • 20
  • 33

1 Answers1

0

Give this a try

You can step through the code with F8 key and adjust each parameter until you get your expected results.

I suggest that you read this post

Public Sub ExportPDF()

    Dim sourceWorkbook As Workbook
    Dim sourceWorksheet As Worksheet

    Dim sourceWorkbookName As String
    Dim pdfName As String

    ' Get workbook name
    sourceWorkbookName = Workbooks("boprov.xlsm").Worksheets("Hoja4").Range("G53").Value

    ' Set reference to objects
    Set sourceWorkbook = Workbooks(sourceWorkbookName)
    Set sourceWorksheet = sourceWorkbook.Worksheets("Bonos en Cartera")

    ' Get pdf name
    pdfName = sourceWorksheet.Range("AA2").Value

    ChDir "C:\Users\GALILEO\Documents\CarterasPDF" 'This is where you set a defult file path.

    If pdfName <> vbNullString Then
        sourceWorksheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
            pdfName, _
            Quality:=xlQualityStandard, _
            IncludeDocProperties:=True, _
            IgnorePrintAreas:=False, _
            OpenAfterPublish:=True
    End If

End Sub
Ricardo Diaz
  • 5,658
  • 2
  • 19
  • 30