PDA

View Full Version : Sleeper: Auto PDF Print and Save Button



Capy_Uther
12-09-2023, 11:10 AM
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

June7
12-09-2023, 11:20 AM
What does "not working" mean - error message, wrong result, nothing happens?

Please post code between CODE tags to retain indentation and readability.