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