创建一个打印到pdf宏以在多个pc上使用 [英] Create a print to pdf macro to use on multiple pcs
问题描述
我正在为我的公司创建一个excel文档,并希望创建一个"print to pdf"任何人都可以使用的按钮。 我可以在我的电脑上创建宏没有问题,但它不能在其他电脑上工作,因为文件路径无效。
I am creating an excel document for my company and would like to create a "print to pdf" button for anyone to use. I can create the macro on my pc with no problems, however it will not work on other pcs because the file paths are not valid.
这就是我想要实现的目标
This is what I want to achieve
任何用户都可以点击"打印"按钮。电子表格中的图标
Any user can click the "print" icon in the spreadsheet
此打印按钮将创建第26页和第26页的pdf。保存在桌面上的工作簿中有27个。
This print button will create a pdf of pages 26 & 27 of the workbook saved on their desktop.
推荐答案
据我了解,你想要找到一个VBA代码,它可以为任何登录的用户提供任何PC的桌面路径吗?
As I understood, all you want to find a VBA code, which can give you a path of Desktop in any PC for any user logged in?
这是一个神奇的陈述,它将为你提供正确的路径桌面:
Here is that magical statement which will give you the correct path of desktop:
desktopPath = Environ("USERPROFILE") & "\Desktop"
Let me know if this exactly was your question?
这篇关于创建一个打印到pdf宏以在多个pc上使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!