By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,226 Members | 1,166 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,226 IT Pros & Developers. It's quick & easy.

Open Ms Outlook using Relative Path

P: n/a
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

Jun 9 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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" <re**************@yahoo.co.uk> wrote in message
news:11**********************@h76g2000cwa.googlegr oups.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

Jun 9 '06 #2

P: n/a
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" <re**************@yahoo.co.uk> wrote in message
news:11**********************@h76g2000cwa.googlegr oups.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


Jun 9 '06 #3

P: n/a
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" <re**************@yahoo.co.uk> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.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" <re**************@yahoo.co.uk> wrote in message
news:11**********************@h76g2000cwa.googlegr oups.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
>

Jun 10 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.