473,387 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Open Ms Outlook using Relative Path

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
3 5776
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: atlantis | last post by:
Hi, I have a very strange problem with xsl:import when usig RELATIVE path on AIX 5.2 server. I have two XSL files in the same directory: "ists_xslt3.xsl" and "ists_xslt3_layout.xsl". This...
1
by: gowens | last post by:
I've been trying to strong name my VB.Net v1.1 assembly with the strong name key that we're using for a project. The strongname.snk file is located in a root-level directory. No matter what I...
2
by: PeterKellner | last post by:
I'm having trouble setting a background style in a master page. The declaration in the master page looks like this: <div id="header_image" runat="server" style="background: transparent...
2
by: Jason Gyetko | last post by:
I'm trying to open a file from VBA using a variable path and am not having very much luck. Can anyone help? This works: retval = Shell("""Excel.EXE"" ""C:\Program files\MyPath\MyFile.xls""",...
2
by: shreeniwas | last post by:
Hi All, I want to open one doc file using javascript. Can anybody suggest any better method. Regards Shree
14
by: C | last post by:
Hi, From my ASP.NET application when the user clicksa button I want to be able to programmatically open Outlook, create a new mail, add attachments and set the body text. Is this possible? ...
0
by: Vahehoo | last post by:
Hi, I am trying to digitally sign an old application in ASP.Net. For that purpose I created a Strong Name Key File. The snk file is located in a root-level directory. in Bin\DG_Key directory....
1
by: ShilpaIvaturi | last post by:
Hi, I am relatively new to dotnet...I need to call an exe from my asp.net website where i am using the following code. System.Diagnostics.Process.Start("exepath"); The problem is this...
9
by: saurabh9gupta | last post by:
I am developing a feedback form in which i want to consume the data in the form like NAME,EMAIL and COMMENTS and then on the click of a button I want OUTLOOK to be opened and the values filled in the...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.