+ Reply to Thread
Results 1 to 10 of 10

windows api commands on mac excel 2011

Hybrid View

mcinnes01 windows api commands on mac... 01-16-2011, 06:15 PM
jaslake Re: windows api commands on... 01-16-2011, 09:19 PM
mcinnes01 Re: windows api commands on... 01-17-2011, 04:59 AM
romperstomper Re: windows api commands on... 01-17-2011, 05:04 AM
romperstomper Re: windows api commands on... 01-17-2011, 05:04 AM
mcinnes01 Re: windows api commands on... 01-17-2011, 05:16 AM
mcinnes01 Re: windows api commands on... 01-17-2011, 05:50 AM
mcinnes01 Re: windows api commands on... 01-17-2011, 05:58 AM
romperstomper Re: windows api commands on... 01-17-2011, 06:40 AM
mcinnes01 Re: windows api commands on... 01-24-2011, 05:37 AM
  1. #1
    Forum Contributor mcinnes01's Avatar
    Join Date
    05-25-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    449

    windows api commands on mac excel 2011

    Hi,

    I have a new project I have almost finished, however during testing I tried it on a mac as some of my users have mac's. Some of my code has windows API in it, such as for creating folders and calling word and pinging the mail server.

    Basically it doesn't work on a mac and I'm guessing it is because of the API stuff, is there any way to get it to work on a mac?
    Last edited by mcinnes01; 01-24-2011 at 05:37 AM.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: windows api commands on mac excel 2011

    Hi mcinnes01

    Much of my development has been in Windows for Mac users. It's a major change in direction and a significant cost commitment but I've found that Fusion works wonderfully well.

    John
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Forum Contributor mcinnes01's Avatar
    Join Date
    05-25-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    449

    Re: windows api commands on mac excel 2011

    Hi,

    Sorry for my ignorance but what is fusion and how do I go about using this?

    Many thanks,

    Andy

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

    Re: windows api commands on mac excel 2011

    You cannot use Win API on a Mac, so you have to run windows in a virtual machine, for which you need software such as Parallels, VMWare Fusion or Virtualbox. You also of course need a licensed copy of Windows for each machine.
    I don't see why, or how, you would use Win API rather than automation to run Word though
    Everyone who confuses correlation and causation ends up dead.

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

    Re: windows api commands on mac excel 2011

    You cannot use Win API on a Mac, so you have to run windows in a virtual machine, for which you need software such as Parallels, VMWare Fusion or Virtualbox. You also of course need a licensed copy of Windows for each machine.
    I don't see why, or how, you would use API rather than automation to run Word though

  6. #6
    Forum Contributor mcinnes01's Avatar
    Join Date
    05-25-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    449

    Re: windows api commands on mac excel 2011

    Hi RS,

    So I guess it is possible to work around certain code and write it in a way that can be used on both mac and pc. Here is an example of a module I think will trip up, I can't remember exactly which bits fail as I was borrowing a friends mac when I tested it, but I have a feeling this won't work as it is. What can I do to get the same result but use it on a mac as well?

    Sub ping(DocFile As String, xFile As String)
      
        Dim nRes
        Dim x
        Dim xBook As Workbook
        Dim ish As Worksheet
       
        Set xBook = ActiveWorkbook
        Set ish = xBook.Sheets(2)
       With CreateObject("WScript.Shell")
            nRes = .Run("%comspec% /c ping.exe -n " & 1 & " -w " & 250 _
              & " 192.168.0.5 | find ""TTL="" > nul 2>&1", 0, True)
       End With
       
       If nRes <> 0 Then
       
        If ish.Range("DOCTYPE") = "" Then
            GoTo REQUEST
        ElseIf ish.Range("DOCTYPE") = "REQUEST" Then
            GoTo REQUEST
        Else
            GoTo AUTH
        End If
        
    REQUEST:
       MsgBox ("Unable to connect to the mail server." & vbNewLine & vbNewLine _
            & "Please print off the word document, if you haven't already done so " & vbNewLine _
            & "and give it the Authorisor. The file can be found in a folder " & vbNewLine _
            & "called 'STAFF CHANGES BACKUP' on your desktop. Alternatively email " & vbNewLine _
            & "both the excel file and word document relating to this request to " & vbNewLine _
            & "the Authorisor")
            
            'Set WordApp = GetObject(, "word application")
            'If Err.Number <> 0 Then 'word isn't running
            Set WordApp = CreateObject("word.application")
            'End If
            'On Error GoTo 0
        With WordApp
            Set WordDoc = .documents.Open(DocFile)
            .Visible = True
        End With
            
        GoTo NextStep
        
    AUTH:
        MsgBox ("Unable to connect to the mail server." & vbNewLine & vbNewLine _
            & "Please print off the word document, if you haven't already done so " & vbNewLine _
            & "and give it HR and " & ish.Range("MNAME") & ". The file can be found in a folder " & vbNewLine _
            & "called 'STAFF CHANGES BACKUP' on your desktop. Alternatively email " & vbNewLine _
            & "both the excel file and word document relating to this request to " & vbNewLine _
            & "HR and " & ish.Range("MNAME") & ".")
            
            'Set WordApp = GetObject(, "word application")
            'If Err.Number <> 0 Then 'word isn't running
            Set WordApp = CreateObject("word.application")
            'End If
            'On Error GoTo 0
        With WordApp
            Set WordDoc = .documents.Open(DocFile)
            .Visible = True
        End With
            
        GoTo NextStep
            
    NextStep:
    opdoc:  If WordDoc Is Nothing Then
                GoTo opdoc
            Else
    WordApp.Visible = False
         x = MsgBox("Would you like to print the change request?", vbQuestion + vbYesNo, "PRINT CHANGE REQUEST")
    
                If x = vbYes Then
                    WordDoc.PrintOut
                    Call Utilities.closebk
                    Exit Sub
                Else
                    Call Utilities.closebk
                    Exit Sub
                End If
            End If
        
        
        Else
            FileDoc = DocFile
            FileX = xFile
            Call Emailer.MAuth(FileDoc, FileX)
            Call Utilities.closebk
            
        End If
    
    End Sub

  7. #7
    Forum Contributor mcinnes01's Avatar
    Join Date
    05-25-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    449

    Re: windows api commands on mac excel 2011

    I also think that this save string won't work either?

    Cleanup:
        Deskstr = CreateObject("WScript.Shell").Specialfolders("Desktop") _
              & Application.PathSeparator & "STAFF CHANGES BACKUP"
        
        If Dir(Deskstr, vbDirectory) = "" Then MkDir Deskstr
    
    SaveStr = Deskstr & Application.PathSeparator & "CHANGE " & ish.Range("DOCTYPE") _
            & " - " _
            & Format(Now, "dd-mm-yy - hh.mm")

  8. #8
    Forum Contributor mcinnes01's Avatar
    Join Date
    05-25-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    449

    Re: windows api commands on mac excel 2011

    Is this an alternative that will work or not? CreateObject("Scripting.FileSystemObject")
    And I guess you can't call "ping.exe" in a mac either, is there an alternative to this also?

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

    Re: windows api commands on mac excel 2011

    I don't believe you can use the Scripting objects either since they are provided with Internet Explorer and as far as I know there is no Mac equivalent. (I don't use my Mac for work as the compatibility is too much hassle and VBA runs too slowly)

  10. #10
    Forum Contributor mcinnes01's Avatar
    Join Date
    05-25-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    449

    Re: windows api commands on mac excel 2011

    Thanks RS, I think I will just tell IT to install VMWARE on anyones mac who needs to use it then they can just run windows.

    Cheers

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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