简体   繁体   中英

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. The user presses finish which takes the excel data and auto populates it into a 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:

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:

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:

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).

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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