简体   繁体   English

在macintosh上使用excel vba打开powerpoint

[英]opening powerpoint using excel vba on a macintosh

I have done a lot of research on this topic, and can't seem to find anything that works for me. 我对此主题进行了大量研究,但似乎找不到适合我的方法。 What my project does is the user fills out the excel file with data. 我的项目所做的是用户用数据填充excel文件。 The user presses finish which takes the excel data and auto populates it into a powerpoint. 用户按下完成按钮,这将获取excel数据并将其自动填充到PowerPoint中。 The powerpoint "called "ExcelUseThisOne") is already made and is saved in a folder (called "PowerPoint") on the desktop. I want the excel file to open the powerpoint, auto populate it, save it, then close powerpoint. I have this working on a PC, but not a Mac. Here is my code on opening powerpoint which I thought would work, but doesn't: 简报“称为“ ExcelUseThisOne”)已经制作好并保存在桌面上的文件夹(称为“ PowerPoint”)中。我希望excel文件打开简报,自动填充它,保存,然后关闭简报。可以在PC上使用,但不能在Mac上使用。这是我打开Powerpoint的代码,我认为该代码可以运行,但无效:

UserName = InputBox(Prompt:="You name please.", Title:="ENTER YOUR NAME", Default:="all LOWERCASE and ONE WORD")
Dim strPresPath As String, strExcelFilePath As String, strNewPresPath As String
strPresPath = ":Users:" & UserName & ":Desktop:PowerPoint:ExcelUsesThisOne.ppt"
FilePath = ":Users:" & UserName & ":Desktop:PowerPoint:NewPresentation.ppt"
strNewPresPath = FilePath
Set oPPTApp = CreateObject("PowerPoint.Application")
oPPTApp.Visible = msoTrue
Set oPPTFile = oPPTApp.Presentations.Open(strPresPath)

Any help would be great! 任何帮助将是巨大的! Thank you. 谢谢。

I'm not certain but I seem to recall that Mac does not use file extensions, so you could try this on Mac: 我不能肯定,但我似乎记得,苹果使用的文件扩展名,所以你可以尝试这样在Mac:

strPresPath = ":Users:" & UserName & ":Desktop:PowerPoint:ExcelUsesThisOne"

Other possible reason is that the username has been entered incorrectly? 其他可能的原因是用户名输入错误? I think this will work on a mac, instead of the input box you can try one of these options: 我认为这将在Mac上运行,而不是输入框,您可以尝试以下选项之一:

strPresPath = ":Users:" & Environ("username") & ":Desktop:PowerPoint:ExcelUsesThisOne"

Or try that approach with the file extension (again, I'm not 100% certain about the file extensions not used on Mac OS). 或尝试使用文件扩展名的方法(同样,我不确定100%确定Mac OS上未使用的文件扩展名)。

You may need to volume name, eg,: 您可能需要卷名,例如:

strPresPath = "volume_name:Users:..."`

Otherwise, you can debug by checking the path of some other workbook, which should show you the correct way to formulate the path string. 否则,您可以通过检查其他工作簿的路径来进行调试,这将向您显示正确的方式来构造路径字符串。

Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM