workbooks.add type mismatch error on mac

Copper Contributor

I have a number of spreadsheets that are used on both windows and mac, I have two public procedures that create a second workbook and copy some content, they have a similar construct

ie.

Public Sub GenerateWeeklyReport()
  Dim SourceWB As String
  Dim TargetWB As String
  Dim WB As Workbook
  Let SourceWB = ActiveWorkbook.Name
  Set WB = Workbooks.Add
  Let TargetWB = ActiveWorkbook.Name
  Application.ScreenUpdating = False

  Application.DisplayAlerts = False

  --Copies stuff between SourceWB and TragetWB

  Application.DisplayAlerts = True

  Application.ScreenUpdating = True

End Sub

 

Both Macros work perfectly on Windows, one macro works properly on mac, however the second macro (Both in the same module), produces a type mismatch error on set WB=workbooks.add

 

---I have just moved the second sub to its own module and now it works ok...could this be yet another mac feature?

0 Replies