+ Reply to Thread
Results 1 to 7 of 7

Mac Incompatibility with script done in Windows

  1. #1
    Registered User
    Join Date
    05-19-2021
    Location
    England
    MS-Off Ver
    365
    Posts
    7

    Mac Incompatibility with script done in Windows

    Hi good day Everybody,

    I've developed a small script for importing CSV files and automatically send them to a pre-defined email account. I've tested it on several windows PC's and it's working, but I cannot make it run on mac....

    To be honest I'm newby with all this vba but I'm struggling to find any answer on the internet.

    Thus, any help or guidance is much welcomed!!!

    Please see below:

    Sub Get_Data_From_File()
    Dim sPath As String
    Dim NewMail As CDO.Message
    Dim mailConfiguration As CDO.Configuration
    Dim fields As Variant
    Dim msConfigURL As String


    sPath = Application.GetOpenFilename(Title:="Browse for your file", FileFilter:="Excel Files (*.xls*; *.csv), *.xls*;*.csv")


    Set NewMail = New CDO.Message
    Set mailConfiguration = New CDO.Configuration
    Set fields = mailConfiguration.fields

    With NewMail
    .Subject = "data file"
    .From = "emailadress"
    .To = "emailadress"
    .Subject = sPath
    .TextBody = "test"
    .AddAttachment (sPath)


    End With

    msConfigURL = "configadress"

    With fields
    .Item(msConfigURL & "/smtpusessl") = True
    .Item(msConfigURL & "/smtpauthenticate") = 1

    .Item(msConfigURL & "/smtpserver") = "smtp.gmail.com"
    .Item(msConfigURL & "/smtpserverport") = 465
    .Item(msConfigURL & "/sendusing") = 2
    .Item(msConfigURL & "/sendusername") = "emailadress"

    .Item(msConfigURL & "/sendpassword") = "password"

    .Update

    End With

    NewMail.Configuration = mailConfiguration
    NewMail.Send

    Workbooks.OpenText Filename:= _
    sPath, DataType:=xlDelimited, Semicolon:=True, Local:=True


    Set openbook = Application.Workbooks.Open(sPath)
    openbook.Sheets(1).Range("A1:P30000").Copy
    ThisWorkbook.Worksheets("Raw Data").Range("A1").PasteSpecial xlPasteValues
    openbook.Close False



    MsgBox "data successfully processed", vbInformation



    End Sub



    Thanks!!!!!!

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,436

    Re: Mac Incompatibility with script done in Windows

    I don't have a Mac so I cannot help much, but I suspect that others (who perhaps can help) will need more information. And it might assist you in self diagnosing the problem.

    1. Does the code compile?
    2. What happens when you run it? How does it fail? Where does it fail? Is there an error message?
    3. Have you stepped through the code using F8, or whatever the Mac equivalent is?
    4. Are there any missing References?
    5. Similar to step 3 above, can you isolate and test each section of the code? That is, does the dialogue box work? Does creating and sending an email work? Does creating and sending an email with an (fixed/pre-defined) attachment work?
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,436

    Re: Mac Incompatibility with script done in Windows

    Just wondering why you're using Paste Special | Values? If it's csv file, it won't have any formulae or values.

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Mac Incompatibility with script done in Windows

    There are so many issues with VBA on Macs that you will need to deal with. I suggest you start here: https://www.macexcel.com/examples/mailpdf/macmail/
    Rory

  5. #5
    Registered User
    Join Date
    05-19-2021
    Location
    England
    MS-Off Ver
    365
    Posts
    7

    Re: Mac Incompatibility with script done in Windows

    Hi TMS,

    the code works in a couple of Windows laptops but when trying to run in mac there is a msg saying compile error....I guess there is an issue as rorya pointed out...

    Doing paste special for not any particular reason, thanks for pointing out!!!

    Cheer

  6. #6
    Registered User
    Join Date
    05-19-2021
    Location
    England
    MS-Off Ver
    365
    Posts
    7

    Re: Mac Incompatibility with script done in Windows

    Thanks rorya,

    I'm checking the webpage and I see that using scripts from windows in mac is not so straight forward!

    Cheers

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,436

    Re: Mac Incompatibility with script done in Windows

    Does the compile error highlight a specific line of code? My initial thought was the dialogue box may be an issue but I know nothing about Macs.

+ 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. Excel Formatting Incompatibility Mac/Windows
    By SoGalinSoCal in forum Excel General
    Replies: 0
    Last Post: 05-22-2015, 03:36 PM
  2. code/script to connect macro to livelink archive windows imaging
    By giomckenzie12 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-30-2013, 05:50 AM
  3. 64 bit incompatibility
    By AndyLitch in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-05-2013, 04:39 AM
  4. Macro script hangs on start in Windows 8
    By drjogora in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-27-2013, 12:15 PM
  5. windows task scheduler VBS script to run macro
    By els050676 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-16-2013, 09:13 AM
  6. "Method 'Range' of object '_Worksheet' failed" error in Windows Script Host
    By jikenj in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-16-2010, 02:18 PM
  7. Version Incompatibility
    By JUnk in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-04-2005, 11:05 AM

Tags for this Thread

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