Link to home
Start Free TrialLog in
Avatar of Bryce Bassett
Bryce BassettFlag for United States of America

asked on

VBA woes in Office 2011 for Mac

I've used VBA since Office 2007 for Windows came out.  I have a client who needs a solution in Office 2011 for Mac, and I've been a PC guy all my life so I'm struggling with some basic concepts.

Filename and path syntax is frustrating me.  Trying this simple test to get to a file I know is there but it says the file does not exist.  Is something wrong with my path?

file2open = "/Library/Application Support/HPC_Content/Animals/Cat.tif"
ActivePresentation.Slides(2).Shapes.AddPicture fileName:=file2open, linktofile:=msoFalse, savewithdocument:=msoTrue, Left:=100, Top:=100

Also, can you point me to how I would open a file picker dialog in VBA for mac?

I'm sure I'll have lots more questions as I struggle through this transition.  Anybody know of a good resource for "Making the transition from VBA for Windows to VBA for Mac"?

thanks.
SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rgonzo1971
Rgonzo1971

Hi,

I forgot to put the function neede for the code above

Function FileOrFolderExistsOnMac(FileOrFolder As Long, FileOrFolderstr As String) As Boolean
'By Ron de Bruin
'30-July-2012
'Function to test whether a file or folder exist on a Mac.
'Uses AppleScript to avoid the problem with long file names
    Dim ScriptToCheckFileFolder As String
    ScriptToCheckFileFolder = "tell application " & Chr(34) & "Finder" & Chr(34) & Chr(13)
    If FileOrFolder = 1 Then
        ScriptToCheckFileFolder = ScriptToCheckFileFolder & "exists file " & _
                                  Chr(34) & FileOrFolderstr & Chr(34) & Chr(13)
    Else
        ScriptToCheckFileFolder = ScriptToCheckFileFolder & "exists folder " & _
                                  Chr(34) & FileOrFolderstr & Chr(34) & Chr(13)
    End If
    ScriptToCheckFileFolder = ScriptToCheckFileFolder & "end tell" & Chr(13)
    FileOrFolderExistsOnMac = MacScript(ScriptToCheckFileFolder)
End Function

Open in new window

Avatar of Bryce Bassett

ASKER

Thanks, both.  I found some resources that said Mac OS no longer uses the colon to separate folders, but obviously it does.

Helpful resources.  The MacScript method is especially helpful.  I adjusted it to pick any file and not filter for certain types, but you pointed me in the right direction