none
using CallByName so Mac VBA does throw a compile errow because a userform is being shown modeless RRS feed

  • Question

  • I had this code working a year ago but somehow it is now not working.  The problem is:

    • I have a cross platform (Win and Mac) vba addin for Word
    • I want the Win version to show a modeless userform while the Mac version shows the information in a message box e.g.

    If system.OperatingSystem = "Macintosh" then
        msgbox ......
    else
       frmTB.show vbmodeless
       ....
    end if

    Unfortuantely the Mac throws a compile error as soon as it sees the "frmTB.show vbmodeless" even though it never needs to go near it.

    A year ago I am SURE that I managed to get around this problem by using (or something like this)

          CallByName frmTB, "Show", vbMethod, vbModeless

    Does anyone have a suggestion for how I can have one source program that will show a modeless userform on the windows side but not cause the Mac to throw a compile error?

    And assistance very gratefully received.

    Peter Evans
    eMarking Assistant: helping teachers provide assessment feedback and use marking Rubrics

    Monday, January 10, 2011 4:21 AM

Answers

  • How about using the compiler constant "Mac" and

    #If Mac Then

    ' Do the Mac stuff

    #Else

    ' Do the Windows stuff

     #End If

    ?

    AFAIK these actually function at runtime even though they are "compiler" constants etc. This approach works in Word 2010/Mac Word 2004 but I haven't checked with any earlier versions of /VBA/.

     


    Peter Jamieson
    • Proposed as answer by Bruce Song Thursday, January 13, 2011 7:22 AM
    • Marked as answer by Bruce Song Tuesday, January 18, 2011 9:56 AM
    Wednesday, January 12, 2011 9:23 PM

All replies

  • I have published an unprotected .doc containing the the code so you can look at it to see it working on the Windows and Mac sides.

    http://dl.dropbox.com/u/18519629/demo%20problems.doc

    You will need to comment out the code depending on what platform you are lookng at.

    Does anyone have a suggestion for how I can have one source program that will show a modeless userform on the windows side but not cause the Mac to throw a compile error?

    And assistance very gratefully received.

    Peter Evans
    eMarking Assistant: helping teachers provide assessment feedback and use marking Rubrics

    Wednesday, January 12, 2011 1:44 PM
  • How about using the compiler constant "Mac" and

    #If Mac Then

    ' Do the Mac stuff

    #Else

    ' Do the Windows stuff

     #End If

    ?

    AFAIK these actually function at runtime even though they are "compiler" constants etc. This approach works in Word 2010/Mac Word 2004 but I haven't checked with any earlier versions of /VBA/.

     


    Peter Jamieson
    • Proposed as answer by Bruce Song Thursday, January 13, 2011 7:22 AM
    • Marked as answer by Bruce Song Tuesday, January 18, 2011 9:56 AM
    Wednesday, January 12, 2011 9:23 PM