Apple Mac File Path

Aviles

Board Regular
Joined
Dec 17, 2008
Messages
141
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.
 

Forum statistics

Threads
1,081,617
Messages
5,360,044
Members
400,565
Latest member
Tommy O

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top