Porting Macro to Mac - Compile Error

skania

New Member
Joined
Jul 1, 2013
Messages
1
I've developed a macro on Windows that works perfectly, I had a problem with the opening of files - now I have a problem saving the file. Here is the code tossing the error:

Code:
Sub asktosave()
Dim sav As Integer
Dim file_name As Variant


sav = MsgBox("Would you like to save this file?", 4, "Save?")
If sav = vbYes Then Call GetFolder("Select Folder Location")


End Sub



Function GetFolder(strPath As String) As String
Dim sItem As String
Dim sFile As String
Dim fldr As FileDialog
Set fldr = Application.FileDialog(msoFileDialogFolderPicker)


With fldr
    .Title = "Select a Folder"
    .AllowMultiSelect = False
    .InitialFileName = strPath


    If .Show <> -1 Then GoTo NextCode
    sItem = .SelectedItems(1)
End With


NextCode:
GetFolder = sItem
Set fldr = Nothing


sFile = "\" & sSubID & "-" & sSubSession & "-synced.txt"
ActiveWorkbook.SaveAs Filename:=sItem & sFile, FileFormat:=xlTextMSDOS, CreateBackup:=False
End Function

The error I get is when I run on a Mac, it says:
"Compile error:
User-defined type not defined."

And the debugger has the Function GetFolder(strPath...) highlighted.
I have no idea what the problem is, it was working just fine in Windows - anyone have any suggestions?
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
The FileDialog doesn't exist on Macs. Have a look at Ron's tips here - I think there's an AppleScript alternative.
 
Upvote 0

Forum statistics

Threads
1,214,875
Messages
6,122,044
Members
449,063
Latest member
ak94

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top