+ Reply to Thread
Results 1 to 8 of 8

Portable VBA to support OSX and Windows

  1. #1
    Forum Contributor
    Join Date
    02-26-2014
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    173

    Portable VBA to support OSX and Windows

    I have a healthy sized macro (>500k as xlam) that was written against Excel 2010 for Windows. The macro examines ActiveSheet, formats it differently depending on the type of report, and saves it to a SAMBA network share, mapped as a drive letter and accessed through the drive path (as opposed to UNC pathing). It is also responsible for reading in and writing some simple lists that are delimitated with CRLF, also stored in that SAMBA share.

    Making the macro work on my OSX laptop would be helpful but is not essential, so I am trying to evaluate the considerations that need to be made for my code to be portable between platforms. Below is a list of considerations I am aware of. If you have any tips to address these concerns or know of concerns I haven't thought of, please chime in!

    1) Pathing: Maybe set a PATH_DELIM global constant in my bootstrapping that tells it which way to flip the "/"?

    2) Newline termination: Since Windows and OSX will both be reading/writing to the same ASCII TXT files, I think I need to pick a convention and use vbCrLf specifically rather than vbNewLine even if Split(sTextReadIn, vbNewLine) will see CRLF and split anyways. This is to maintain readability of the TXT files in Window's Notepad.

    3) Anything else? Are there Windows only functions that don't appear in OSX VBA? Do any common functions behave differently between the two platforms?

    Thank you.
    Last edited by smpita; 11-03-2017 at 02:41 PM.

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Portable VBA to support OSX and Windows

    Hi,

    Re #1 application.pathseparator should be of benefit.

    There are many small differences between Mac and Windows VBA and no complete listing that I am aware of. Have you not tested the code on your laptop?
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Forum Contributor
    Join Date
    02-26-2014
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    173

    Re: Portable VBA to support OSX and Windows

    Quote Originally Posted by xlnitwit View Post
    Hi,

    Re #1 application.pathseparator should be of benefit.

    There are many small differences between Mac and Windows VBA and no complete listing that I am aware of. Have you not tested the code on your laptop?
    Not yet. This is a project planned for next week. As I know it wouldn't work out of box, I haven't allocated the time test it. I thought I would poll for any known tricks like Application.PathSeparator before I end up reinventing them on my own.

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Portable VBA to support OSX and Windows

    As you have not posted any code, you are essentially asking for a list of all known differences and, as I mentioned earlier, there is no such thing to my knowledge.

  5. #5
    Forum Contributor
    Join Date
    02-26-2014
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    173

    Re: Portable VBA to support OSX and Windows

    Quote Originally Posted by xlnitwit View Post
    As you have not posted any code, you are essentially asking for a list of all known differences and, as I mentioned earlier, there is no such thing to my knowledge.
    I would have to disagree. I specifically outlined 2 issues I know I will have. Path separations and newline termination handling. I did leave the post open with #3 so that anyone with direct experience in porting VBA from Windows to OSX could chime in on any area they feel important without feeling like they are off topic for the thread. You have already solved issue #1. Thank you for your contribution.

    Edit:

    Earlier, I tossed some rep your way for the .PathSeparator suggestion. I have not marked this thread as solved because I intend to use it to aggregate problems that I face regarding this topic so that anyone facing this issue can use it to help understand some of the issues they may face. As you have pointed out, no such list exists.
    Last edited by smpita; 11-03-2017 at 08:02 PM.

  6. #6
    Forum Guru
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,859

    Re: Portable VBA to support OSX and Windows

    Ron de Bruin has a list of 'Problems and system and version information (Mac): http://www.rondebruin.nl/mac/section1.htm

    In addition to file separator differences (already mentioned), my speculation is that use of non-standard items (e.g. API [Application Programming Interfaces]) will cause porting problems.

    Conditional compilation will probably help also. See https://sysmod.wordpress.com/2016/09...el-macwin3264/

    I hope this helps a little.

    Lewis

  7. #7
    Forum Contributor
    Join Date
    02-26-2014
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    173

    Re: Portable VBA to support OSX and Windows

    Quote Originally Posted by LJMetzger View Post
    Ron de Bruin has a list of 'Problems and system and version information (Mac): http://www.rondebruin.nl/mac/section1.htm

    In addition to file separator differences (already mentioned), my speculation is that use of non-standard items (e.g. API [Application Programming Interfaces]) will cause porting problems.

    Conditional compilation will probably help also. See https://sysmod.wordpress.com/2016/09...el-macwin3264/

    I hope this helps a little.

    Lewis
    Both links look really useful. I'm sure that will help a lot, thanks!

  8. #8
    Forum Contributor
    Join Date
    02-26-2014
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    173

    Re: Portable VBA to support OSX and Windows

    Considering the quality of the external links, I'm marking this thread as solved. Ron de Bruin covers a lot of ground.

+ 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. Opening a text file from a Windows Portable Device
    By aremarti in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-25-2016, 12:33 PM
  2. Class does not support Automation or does not support expected interface
    By ccs_1981 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-28-2015, 05:57 AM
  3. Windows Technical Support - Scam?
    By MarvinP in forum The Water Cooler
    Replies: 22
    Last Post: 12-25-2014, 10:32 PM
  4. UDF not portable
    By Pilule in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-15-2014, 10:02 PM
  5. runtime 430 error- Class does not support Automation or does not support...
    By kimcole5 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-22-2012, 01:27 PM
  6. Portable Hyperlinks?
    By BdgBill in forum Excel General
    Replies: 1
    Last Post: 05-10-2007, 04:38 PM
  7. portable code...
    By mark in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-05-2005, 04:05 PM

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