Results 1 to 2 of 2
  1. #1
    sroot is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2014
    Posts
    8

    Compile Error When Selecting A Reference

    Hi Guys. I have this module that works great. all it does is tell me if whatever Microsoft office program is open. The problem i get is that when i add the reference Microsoft outlook 14.0 object library i get a compile error "ByRef argument type mismatch" How can i fix this? I call the function to verify outlook is open before an automatic email is sent. Even when i try to use ?IsAppRunning(outlook) in the immediate window it gives me that error unless i remove the reference. Thanks!



    Code:
    Option Compare Database
    
    
    
        Public Enum OfficeAppName
    
           Outlook = 1
            powerpoint = 2
            excel = 3
            Word = 4
            Publisher = 5
            Access = 6
        End Enum
         
        Function IsAppRunning(appName As OfficeAppName) As Boolean
        
        On Error GoTo NotRunning
         
        Dim officeApp As Object
        Dim appString As String
         
       
        IsAppRunning = True
         
       
        Select Case appName
            Case 1
               appString = "Outlook"
            Case 2
               appString = "PowerPoint"
            Case 3
               appString = "Excel"
            Case 4
               appString = "Word"
            Case 5
               appString = "Publisher"
            Case 6
               appString = "Access"
        End Select
         
        
        Set officeApp = GetObject(, appString & ".Application")
         
    ExitProc:
          Exit Function

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 07-24-2013, 02:01 PM
  2. Compile Error: Syntax Error in DoCmd.RunSQL Statement
    By Evilferret in forum Programming
    Replies: 1
    Last Post: 08-27-2012, 12:32 PM
  3. Replies: 2
    Last Post: 06-23-2012, 11:59 PM
  4. Replies: 7
    Last Post: 06-08-2012, 09:55 PM
  5. Replies: 6
    Last Post: 09-28-2011, 09:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums