Forum Discussion
Print with VBA PC vs. MAC
- May 22, 2023
The code you provided should at first glance work on both PC and Mac as it uses standard VBA syntax and does not contain any platform specific commands or functions.
However, there is one part of the code that could potentially cause an error on a Mac due to differences in file path syntax.
In the line where you specify the PDF filename, you are currently using a Windows file path format:
Filename:="C:\tempo.pdf"
On a Mac, the file path should use the forward slash (/) as the path separator and the appropriate Mac file system syntax. You can modify the file path to work on both PC and Mac by using the Application.PathSeparator property, which automatically adapts to the current platform.
Here is an updated version of that line:
Filename:=Application.DefaultFilePath & Application.PathSeparator & "tempo.pdf"
This will use the default file path on the user's machine and append the filename "tempo.pdf" to it, using the appropriate path separator for the platform.
With this modification, the code theoretically should work on both PC and Mac without any issues.
Theoretically, because I do not have a Mac and can try it out.
The code you provided should at first glance work on both PC and Mac as it uses standard VBA syntax and does not contain any platform specific commands or functions.
However, there is one part of the code that could potentially cause an error on a Mac due to differences in file path syntax.
In the line where you specify the PDF filename, you are currently using a Windows file path format:
Filename:="C:\tempo.pdf"
On a Mac, the file path should use the forward slash (/) as the path separator and the appropriate Mac file system syntax. You can modify the file path to work on both PC and Mac by using the Application.PathSeparator property, which automatically adapts to the current platform.
Here is an updated version of that line:
Filename:=Application.DefaultFilePath & Application.PathSeparator & "tempo.pdf"
This will use the default file path on the user's machine and append the filename "tempo.pdf" to it, using the appropriate path separator for the platform.
With this modification, the code theoretically should work on both PC and Mac without any issues.
Theoretically, because I do not have a Mac and can try it out.
- EmiAle79May 28, 2023Copper Contributor
thank you so much!!!! works perfectly now.NikolinoDE
- NikolinoDEMay 28, 2023Platinum ContributorI am glad that I was able to help you with your project.
I wish you continued success with Excel!