View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
sknowles sknowles is offline
external usenet poster
 
Posts: 2
Default Mac VBA compile error - Help!

Hopefully, someone has seen this & knows a work-around - it's making me
crazy.

I'm developing a set of macros (on Win/XP) and testing them on iMacs.
When I open the workbook, I execute (from the ThisWorkbook.Private Sub
Workbook_Open() routine) a series of subroutines in our code module.
Works fine on (several) Windows platforms.

However, on (several) Macs, I get the following error:
"Compile error:
Automation error"

which opens the VBA IDE, with the header of the following routine
highlighted:

Sub MA_Repair_Links(Sheet_Name As String, Replacement_String As String,
_
wBook As Workbook, MA_Return_Code As Integer)
'
' Marketing Budget Toolkit - Repair Links after sheet import
' (c) 2006 Marketing Acumen, LLC
' Macro written Jan 2006 by Steve Knowles
'
Dim wSheet As Worksheet

Set wSheet = MA_Get_Sheet(Sheet_Name, MA_Return_Code, wBook)
wSheet.Select
wSheet.Unprotect Password:=MA_Pwd
wSheet.Cells.Replace What:="=#REF!", _
Replacement:=Replacement_String, LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False

wSheet.Protect Password:=MA_Pwd, UserInterfaceOnly:=True

End Sub

Note: this subroutine is NOT executed from the Workbook_Open event.
Even more interesting (to me), I can later run the routine that calls
this module (after quitting the IDE and manually setting my global
variables), and it works fine!

I'm doing most of my testing on Microsoft Excel X for MacŪ Service
Release 1 (2001), but am getting the same behaviors on other Mac
versions.

Thanks for any insights you can provide...
- Steve Knowles