Consulting

Results 1 to 2 of 2

Thread: Sleeper: Auto PDF Print and Save Button

  1. #1

    Sleeper: 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; 12-09-2023 at 06:01 PM. Reason: Added code tags to supplied code

  2. #2
    VBAX Mentor
    Joined
    Nov 2022
    Location
    The Great Land
    Posts
    337
    Location
    What does "not working" mean - error message, wrong result, nothing happens?

    Please post code between CODE tags to retain indentation and readability.
    How to attach file: Reading and Posting Messages (vbaexpress.com), click Go Advanced below post edit window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Posting Permissions

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