Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Open Ms Outlook using Relative Path

Discussion in 'Information Technology' started by bobdydd, Jul 28, 2006.

  1. bobdydd

    bobdydd
    Expand Collapse
    Guest

    Hi Everybody

    Access 2000, Outlook 2000 Windows XP

    I am running the code below to open Microsoft Outlook from a Command
    Button. It works fine until I tried it on a machine that has Office
    installed on something other than the "C" drive.

    So can anyone advise me how to open Outlook by using a relative path
    rather than the code I am using here.

    Thanks
    Bob

    Private Sub CmdOpen_Click()
    On Error GoTo Err_Error_Click
    Dim MyAppID, ReturnValue
    Dim MyXL As Object
    Set MyXL = GetObject(, "Outlook.Application")
    MsgBox "OUTLOOK IS ALREADY RUNNING", vbInformation, "Oops!"
    Exit_Error_Click:
    Exit Sub
    Err_Error_Click:
    If Err.Number = 429 Then
    MyAppID = Shell("C:\Program Files\Microsoft
    Office\Office\OUTLOOK.EXE", 1)
    Else
    MsgBox Err.Description
    End If
    Resume Exit_Error_Click
    End Sub
     
  2. Loading...


  3. Douglas J Steele

    Douglas J Steele
    Expand Collapse
    Guest

    Not sure I see how being able to use a relative path will help. Relative to
    what? Just because you know where Access has been installed doesn't
    guarantee that Outlook has been installed to the same location.

    I believe you can use the code in http://www.mvps.org/access/api/api0023.htm
    at "The Access Web" to find the complete path. Of course, you'd need to know
    where the pst files are stored...

    --
    Doug Steele, Microsoft Access MVP
    http://I.Am/DougSteele
    (no e-mails, please!)


    "bobdydd" <reallyuseful2004@yahoo.co.uk> wrote in message
    news:1149875659.662280.207530@h76g2000cwa.googlegroups.com...
    > Hi Everybody
    >
    > Access 2000, Outlook 2000 Windows XP
    >
    > I am running the code below to open Microsoft Outlook from a Command
    > Button. It works fine until I tried it on a machine that has Office
    > installed on something other than the "C" drive.
    >
    > So can anyone advise me how to open Outlook by using a relative path
    > rather than the code I am using here.
    >
    > Thanks
    > Bob
    >
    > Private Sub CmdOpen_Click()
    > On Error GoTo Err_Error_Click
    > Dim MyAppID, ReturnValue
    > Dim MyXL As Object
    > Set MyXL = GetObject(, "Outlook.Application")
    > MsgBox "OUTLOOK IS ALREADY RUNNING", vbInformation, "Oops!"
    > Exit_Error_Click:
    > Exit Sub
    > Err_Error_Click:
    > If Err.Number = 429 Then
    > MyAppID = Shell("C:\Program Files\Microsoft
    > Office\Office\OUTLOOK.EXE", 1)
    > Else
    > MsgBox Err.Description
    > End If
    > Resume Exit_Error_Click
    > End Sub
    >
     
  4. bobdydd

    bobdydd
    Expand Collapse
    Guest

    Hi Doug

    I was probably barking up the wrong tree with relative paths
    My work buddy sent me this code which does the trick, although I would
    like to try it on a PC that has MS Office installed on somewhere other
    than the "C" drive.

    Anyways thanks for the reply and here is the code I'm using. You may be
    able to tidy it up.

    Private Sub CmdOpen_Click()
    On Error GoTo Err_Error_Click
    Dim MyAppID, ReturnValue
    Dim MyXL As Object
    Set MyXL = GetObject(, "Outlook.Application")
    MsgBox "OUTLOOK IS ALREADY RUNNING", vbInformation, "Oops!"
    Exit_Error_Click:
    Exit Sub
    Err_Error_Click:
    If Err.Number = 429 Then
    Dim oShell As Object
    Set oShell = CreateObject("WScript.Shell")
    oShell.Run "Outlook"
    DoCmd.Close
    Else
    MsgBox Err.Description
    End If
    Resume Exit_Error_Click
    End Sub

    Douglas J Steele wrote:
    > Not sure I see how being able to use a relative path will help. Relative to
    > what? Just because you know where Access has been installed doesn't
    > guarantee that Outlook has been installed to the same location.
    >
    > I believe you can use the code in http://www.mvps.org/access/api/api0023.htm
    > at "The Access Web" to find the complete path. Of course, you'd need to know
    > where the pst files are stored...
    >
    > --
    > Doug Steele, Microsoft Access MVP
    > http://I.Am/DougSteele
    > (no e-mails, please!)
    >
    >
    > "bobdydd" <reallyuseful2004@yahoo.co.uk> wrote in message
    > news:1149875659.662280.207530@h76g2000cwa.googlegroups.com...
    > > Hi Everybody
    > >
    > > Access 2000, Outlook 2000 Windows XP
    > >
    > > I am running the code below to open Microsoft Outlook from a Command
    > > Button. It works fine until I tried it on a machine that has Office
    > > installed on something other than the "C" drive.
    > >
    > > So can anyone advise me how to open Outlook by using a relative path
    > > rather than the code I am using here.
    > >
    > > Thanks
    > > Bob
    > >
    > > Private Sub CmdOpen_Click()
    > > On Error GoTo Err_Error_Click
    > > Dim MyAppID, ReturnValue
    > > Dim MyXL As Object
    > > Set MyXL = GetObject(, "Outlook.Application")
    > > MsgBox "OUTLOOK IS ALREADY RUNNING", vbInformation, "Oops!"
    > > Exit_Error_Click:
    > > Exit Sub
    > > Err_Error_Click:
    > > If Err.Number = 429 Then
    > > MyAppID = Shell("C:\Program Files\Microsoft
    > > Office\Office\OUTLOOK.EXE", 1)
    > > Else
    > > MsgBox Err.Description
    > > End If
    > > Resume Exit_Error_Click
    > > End Sub
    > >
     
  5. Douglas J. Steele

    Douglas J. Steele
    Expand Collapse
    Guest

    What's the intent? Simply to open Outlook, but not to do anything with it?

    Try:

    Dim objOutlook As Object

    Private Sub CmdOpen_Click()
    On Error GoTo Err_Error_Click

    Set outOutlook = GetObject(, "Outlook.Application")
    MsgBox "OUTLOOK IS ALREADY RUNNING", vbInformation, "Oops!"

    Exit_Error_Click:
    Exit Sub

    Err_Error_Click:
    If Err.Number = 429 Then
    Set objOutlook = CreateObject("Outlook.Application")
    Else
    MsgBox Err.Description
    End If
    Resume Exit_Error_Click

    End Sub



    --
    Doug Steele, Microsoft Access MVP
    http://I.Am/DougSteele
    (no private e-mails, please)


    "bobdydd" <reallyuseful2004@yahoo.co.uk> wrote in message
    news:1149887550.074587.180120@y43g2000cwc.googlegroups.com...
    > Hi Doug
    >
    > I was probably barking up the wrong tree with relative paths
    > My work buddy sent me this code which does the trick, although I would
    > like to try it on a PC that has MS Office installed on somewhere other
    > than the "C" drive.
    >
    > Anyways thanks for the reply and here is the code I'm using. You may be
    > able to tidy it up.
    >
    > Private Sub CmdOpen_Click()
    > On Error GoTo Err_Error_Click
    > Dim MyAppID, ReturnValue
    > Dim MyXL As Object
    > Set MyXL = GetObject(, "Outlook.Application")
    > MsgBox "OUTLOOK IS ALREADY RUNNING", vbInformation, "Oops!"
    > Exit_Error_Click:
    > Exit Sub
    > Err_Error_Click:
    > If Err.Number = 429 Then
    > Dim oShell As Object
    > Set oShell = CreateObject("WScript.Shell")
    > oShell.Run "Outlook"
    > DoCmd.Close
    > Else
    > MsgBox Err.Description
    > End If
    > Resume Exit_Error_Click
    > End Sub
    >
    > Douglas J Steele wrote:
    >> Not sure I see how being able to use a relative path will help. Relative
    >> to
    >> what? Just because you know where Access has been installed doesn't
    >> guarantee that Outlook has been installed to the same location.
    >>
    >> I believe you can use the code in
    >> http://www.mvps.org/access/api/api0023.htm
    >> at "The Access Web" to find the complete path. Of course, you'd need to
    >> know
    >> where the pst files are stored...
    >>
    >> --
    >> Doug Steele, Microsoft Access MVP
    >> http://I.Am/DougSteele
    >> (no e-mails, please!)
    >>
    >>
    >> "bobdydd" <reallyuseful2004@yahoo.co.uk> wrote in message
    >> news:1149875659.662280.207530@h76g2000cwa.googlegroups.com...
    >> > Hi Everybody
    >> >
    >> > Access 2000, Outlook 2000 Windows XP
    >> >
    >> > I am running the code below to open Microsoft Outlook from a Command
    >> > Button. It works fine until I tried it on a machine that has Office
    >> > installed on something other than the "C" drive.
    >> >
    >> > So can anyone advise me how to open Outlook by using a relative path
    >> > rather than the code I am using here.
    >> >
    >> > Thanks
    >> > Bob
    >> >
    >> > Private Sub CmdOpen_Click()
    >> > On Error GoTo Err_Error_Click
    >> > Dim MyAppID, ReturnValue
    >> > Dim MyXL As Object
    >> > Set MyXL = GetObject(, "Outlook.Application")
    >> > MsgBox "OUTLOOK IS ALREADY RUNNING", vbInformation, "Oops!"
    >> > Exit_Error_Click:
    >> > Exit Sub
    >> > Err_Error_Click:
    >> > If Err.Number = 429 Then
    >> > MyAppID = Shell("C:\Program Files\Microsoft
    >> > Office\Office\OUTLOOK.EXE", 1)
    >> > Else
    >> > MsgBox Err.Description
    >> > End If
    >> > Resume Exit_Error_Click
    >> > End Sub
    >> >

    >
     

Share This Page