Apple Mac File Path

Aviles

Board Regular
Joined
Dec 17, 2008
Messages
163
Hi all, I'm working on a spreadsheet for a friend who uses a Mac. I have zero experience on a Mac so I'm hoping I could get some help please.

The below code works on my PC but it fails on his Mac:

Code:
Sub ImportRawReport()


    Application.ScreenUpdating = False


    Sheets("RawReport").Select
    Cells.Select
    Selection.ClearContents
        
    Dim fd As Office.FileDialog
    Set fd = Application.FileDialog(msoFileDialogFilePicker)


    With fd
         .Title = "Select Raw Tx Report"        
        .AllowMultiSelect = False        
        .InitialFileName = "H:\Misc\Projects\Raw File\"
        
    Dim sFile As String
        If .Show = True Then
            sFile = .SelectedItems(1)
        End If
        
    Dim wbkS As Workbook
    Dim wshS As Worksheet


        Set wbkS = Workbooks.Open(Filename:=sFile)
        Set wshS = wbkS.Sheets("Raw Tx Report")
        wshS.UsedRange.Copy Destination:=Sheet7.Range("A1")
        wbkS.Close 'SaveChanges:=False
    
        Set wbkS = Nothing
        Set wshS = Nothing
    End With
    
    Sheets("RawReport").Select
    Dim Arr As Variant
    Dim Rng As Range
    Dim i As Long
    Arr = Array(xlCellTypeBlanks, xlCellTypeConstants)
    For i = 0 To UBound(Arr)
    Set Rng = Columns("B:B").SpecialCells(Arr(i), 22)
        If Not Rng Is Nothing Then
            Rng.EntireRow.Delete
        End If
    Next i
    
    Sheets("RawReport").Select
    Sheets("RawReport").Cells(Rows.Count, 1).End(xlUp).EntireRow.Delete
    
    Sheets("Home").Select
    MsgBox "BMC raw report has been updloaded", , "BMC"
    
    Application.ScreenUpdating = True


End Sub

The error message I'm getting is "Run-time error '91': Object variable or With block variable not set"

When I click on Debug, it points to the ".Title = "Select Raw Tx Report" part of the code.

The file path also needs to change for his Mac, but I'm unsure how to translate this on the code. I'm also not sure what the new path format will be as I have found two versions:

/Users/FristName/Documents/BMC/

iCloud Drive/Documents/BMC/

I believe he's using Mac Office 365 if that is any help.

Thanks in advance.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,213,497
Messages
6,113,998
Members
448,539
Latest member
alex78

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