+ Reply to Thread
Results 1 to 17 of 17

How to Run the Correct Macro in Windows or on Mac

  1. #1
    Registered User
    Join Date
    01-18-2015
    Location
    Kwara, Nigeria
    MS-Off Ver
    2013
    Posts
    16

    How to Run the Correct Macro in Windows or on Mac

    Hello everyone!
    Please I'm looking for the code that can search out the operating system of a machine. I wrote a code with MS Excel 2013, but the person who wants to use the code uses Excel 2011 for MAC. While the program ran perfectly on my Windows, the MAC user said it generated error. i think the problem is with the GetOpenFilename instruction. Please help me out if you can, as I need to submit the job urgently.
    Thank you in advance.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,013

    Re: How to Run the Correct Macro in Windows or on Mac

    You can use conditional compilation :
    Please Login or Register  to view this content.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Registered User
    Join Date
    01-18-2015
    Location
    Kwara, Nigeria
    MS-Off Ver
    2013
    Posts
    16

    Re: How to Run the Correct Macro in Windows or on Mac

    Thank you @romperstomper for your reply.
    But can you please give me a full code? because I've tried virtually all the codes I know but none worked.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,013

    Re: How to Run the Correct Macro in Windows or on Mac

    Have a look at Ron de Bruin's site - he has several Mac code samples.

  5. #5
    Registered User
    Join Date
    01-18-2015
    Location
    Kwara, Nigeria
    MS-Off Ver
    2013
    Posts
    16

    Re: How to Run the Correct Macro in Windows or on Mac

    I've used his codes, still didn't work.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,013

    Re: How to Run the Correct Macro in Windows or on Mac

    Please be more specific than that. What did you use and what happened?

  7. #7
    Registered User
    Join Date
    01-18-2015
    Location
    Kwara, Nigeria
    MS-Off Ver
    2013
    Posts
    16

    Re: How to Run the Correct Macro in Windows or on Mac

    I used these lines of code below...




    Sub WINorMAC()
    ' Test for the operating system.
    If Not Application.OperatingSystem Like "*Mac*" Then
    ' Is Windows.
    Call Select_File_Or_Files_Windows
    Else
    ' Is a Mac and will test if running Excel 2011 or higher.
    If Val(Application.Version) > 14 Then
    Call Select_File_Or_Files_Mac
    End If
    End If
    End Sub

    ***...and I received the error message in the screenshot attached to this reply***
    Error screen.jpg

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,013

    Re: How to Run the Correct Macro in Windows or on Mac

    You forgot to copy the routines that are being called from Ron's website.

  9. #9
    Registered User
    Join Date
    01-18-2015
    Location
    Kwara, Nigeria
    MS-Off Ver
    2013
    Posts
    16

    Re: How to Run the Correct Macro in Windows or on Mac

    Okay. But how do I do that please? Can you give me a complete code?
    Thank you in advance.

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,013

    Re: How to Run the Correct Macro in Windows or on Mac


  11. #11
    Registered User
    Join Date
    01-18-2015
    Location
    Kwara, Nigeria
    MS-Off Ver
    2013
    Posts
    16

    Re: How to Run the Correct Macro in Windows or on Mac

    Thank you. I'll try them and get back to you.

  12. #12
    Registered User
    Join Date
    01-18-2015
    Location
    Kwara, Nigeria
    MS-Off Ver
    2013
    Posts
    16

    Re: How to Run the Correct Macro in Windows or on Mac

    @romperstomper: Could you please copy the codes for me and fix the routine where it's suppose to be? I still tried the link you gave me but it still didn't work. please complete the code for me and paste it here to copy. Thank you.

  13. #13
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,013

    Re: How to Run the Correct Macro in Windows or on Mac

    You need:
    Please Login or Register  to view this content.
    and:
    Please Login or Register  to view this content.
    I am a little concerned that you say this is a job you need to submit; do you mean assignment?

  14. #14
    Registered User
    Join Date
    01-18-2015
    Location
    Kwara, Nigeria
    MS-Off Ver
    2013
    Posts
    16

    Re: How to Run the Correct Macro in Windows or on Mac

    The thing is I'm just learning VBA. My friend gave me a task to write Excel macros to import some tables from MS word, which I did and which worked fine. But the issue is my friend uses MAC, so the program didn't work for him.
    Thank you for the codes. I'll run them and see if they'll work. I just hope that if they work, I can incorporate them in my already working codes, right?

  15. #15
    Registered User
    Join Date
    01-18-2015
    Location
    Kwara, Nigeria
    MS-Off Ver
    2013
    Posts
    16

    Re: How to Run the Correct Macro in Windows or on Mac

    It still says that 'Sub of Function not defined'

  16. #16
    Registered User
    Join Date
    01-18-2015
    Location
    Kwara, Nigeria
    MS-Off Ver
    2013
    Posts
    16

    Re: How to Run the Correct Macro in Windows or on Mac

    @romperstomper: I've gotten a way round the codes, thank you very much.

  17. #17
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: How to Run the Correct Macro in Windows or on Mac

    Is this thread solved? If it is, please mark it as SOLVED using the thread tools (menu at top right hand corner of thread). If it isn't, does below work for you?

    Please Login or Register  to view this content.
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Enable / Disable Macros behaving differently in Excel 2003 from Windows XP to Windows 7
    By TC1980 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-21-2013, 09:09 AM
  2. Replies: 4
    Last Post: 06-20-2013, 09:30 AM
  3. Replies: 0
    Last Post: 03-08-2012, 11:25 AM
  4. Replies: 1
    Last Post: 11-28-2009, 07:17 PM
  5. Replies: 0
    Last Post: 11-28-2009, 01:28 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1