Auto PDF Print and Save Button

Capy_Uther

New Member
Joined
May 14, 2023
Messages
16
Office Version
  1. 365
Platform
  1. Windows
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
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,215,073
Messages
6,122,970
Members
449,095
Latest member
Mr Hughes

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top