Results 1 to 2 of 2

Thread: Auto PDF Print and Save Button

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Auto PDF Print and Save Button

    I use a VBA project with Excel on my job but i just bought a macbook laptop and almost all the VBA works right, im just having some issues with the follow macro that i use with a button to auto print and save as PDF on the folder where i have the excel and auto name it using initials date and some numbers:


    Can anyone help me why is not working on mac ?


    ' Print 1st letter from Name and Last Names
    Sub BotonPDF1()
        Dim CeldaNombre As Range
        Dim CeldaNombreA As Range
        Dim NombreArchivo As String
        Dim RutaArchivo As String
        Dim nombre As Variant, init As Variant
        Set CeldaNombre = Hoja2.Range("A10")
        Set CeldaNombreA = Hoja2.Range("G4")
        If CeldaNombre.Value = "" Then
            NombreArchivo = Format(Now, "ddmmyyyy_") & Mid(CeldaNombreA.Value, 1) & ".pdf"
        Else
            For Each init In Split(Mid(CeldaNombre, 9), " ")
                nombre = nombre & Left(init, 1)
            Next
            NombreArchivo = nombre & "-" & Format(Now, "ddmmyy-") & "12-" & Mid(CeldaNombreA.Value, 1) & ".pdf"
        End If
        ' 2 initials
        RutaArchivo = Application.ActiveWorkbook.Path & Application.PathSeparator & NombreArchivo
        Hoja2.ExportAsFixedFormat Type:=xlTypePDF, Filename:=RutaArchivo, _
        Quality:=xlQualityStandard, IgnorePrintAreas:=False, OpenAfterPublish:=True
        Hoja2.Range("A4").Select
    End Sub
    Last edited by Aussiebear; 05-03-2025 at 04:38 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •