Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Applications / Excel / January 2006



Tip: Looking for answers? Try searching our database.

Mac VBA compile error - Help!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sknowles - 28 Jan 2006 06:28 GMT
Hopefully, someone has seen this & knows a work-around - it's making me
crazy. I don't have a lot of experience writing VBA code for this
platform.

I'm developing a set of macros (on Win/XP) and testing them on Macs.
When I open the workbook, I try to execute (from the
ThisWorkbook.Private Sub Workbook_Open() routine) a series of
house-keeping 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 - even though this routine is not called from the
Workbook_Open routine. (It is called when the user executes a
particular menu command.)

Sub MA_Repair_Links(Sheet_Name As String, _
                   Replacement_String As String, _
                   wBook As Workbook, MA_Return_Code As Integer)

   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

The offending 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
JE McGimpsey - 29 Jan 2006 13:54 GMT
> The offending subroutine is not executed from the Workbook Open event.
> Even more interesting (to me), I can later run the routine that calls
[quoted text clipped - 4 lines]
> Release 1 (2001), but am getting the same behaviors on other Mac
> versions.

Since it runs fine when you've manually set your globals, I can't think
why this would occur.

The first thing I would try is Rob Bovey's Code Cleaner:

   http://www.appspro.com/Utilities/CodeCleaner.htm

Code modules tend to get corrupted over time with editing. It's possible
that there's some corruption that WinVBA ignores but Mac VBA chokes on.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.