Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you open a non-excel file using a VBA marco

Status
Not open for further replies.

cadocs

Technical User
Jun 16, 2005
35
US
Hey guys,

I have been searching the internet trying to answer this questions for some time now.

here is goes...

I am using excel to store information for my notary scheduling business and currently i have userforms that pop up after a certain length of time has passed. The command buttons that are on the form create emails in outlook express, but i want the buttons to open saved emails instead of composing new ones.

Basically, I'm asking, it there a way to open a .eml file. I have seen how you can open excel files using openfile or a shell command, but i can't get it to work for a non-excel file

I tried the code below and others like it but no luck... please help if you can.

Dim myFile As String, getMyFile As Object

Set getMyFile = "E:\CA NOTARY & DOC SIGNERS\Emails\Ameriquest\additional docs for.eml"

myFile = "E:\CA NOTARY & DOC SIGNERS\Emails\Ameriquest\additional docs for.eml"

getMyFile.OpenFile

Geoff
 
You may try something like this:
Dim myFile As String
myFile = "E:\CA NOTARY & DOC SIGNERS\Emails\Ameriquest\additional docs for.eml"
CreateObject("WScript.Shell").Run myFile

Note: Outlook Express is NOT scriptable ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I tries it and it gave me an error:

Run-time error '-2147024894 (80070002)':
Method "Run' of object 'IWshShell3' failed


If I want to be able to manipulate emails through excel, should switch to Microsoft Outlook? Currently to create emails I am using:

HLink = "mailto:"

then addind the headers and the body then using:

ActiveWorkbook.FollowHyperlink (HLink)
 
And this ?
CreateObject("WScript.Shell").Run Chr(34) & myFile & Chr(34)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I just figured it out!!!!

HLink = "E:\CA NOTARY & DOC SIGNERS\Emails\Ameriquest\additional docs for.eml"

ActiveWorkbook.FollowHyperlink (HLink)



The only thing is that there is a pesky error message that pops up that says:

Some files can contain viruses or otherwise be harmful to your computer. It is important to be certain that this file is from a trustworthy source.

Would you like open this file?



Is there any way to disable this error message?
 
I got an even better way that doesn't cause an error message:

HLink = "E:\CA NOTARY & DOC SIGNERS\Emails\Ameriquest\additional docs for.eml"

OR

HLink = "E:\canota~1\Emails\Ameriq~1\additi~1.eml"

Shell Environ("COMSPEC") & " /c start " & HLink


Thanks. Does anyone have any input on using outlook vs outlook express in regards to VBA compatibility?
 
Without a console window:
HLink = "E:\CA NOTARY & DOC SIGNERS\Emails\Ameriquest\additional docs for.eml"
CreateObject("WScript.Shell").Run Chr(34) & HLink & Chr(34)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi every one trying to use the aforementioned code.

Code:
HLink = "t:\EAD\ead.mdb"
CreateObject("WScript.Shell").Run Chr(34) & HLink & Chr(34)
[code]

this works fine but i want to run a marco called "memberprint" using this can i do this using this code ?
 
You have to launch msaccess.exe with the /x switch.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 

HLink = "t:\EAD\ead.mdb /x Memberprint"
CreateObject("WScript.Shell").Run Chr(34) & HLink & Chr(34)

when using the code above i get a error of

Method 'Run' of object 'Iwshshell3' failed
 
HLink = "msaccess.exe ""t:\EAD\ead.mdb"" /x Memberprint"
CreateObject("WScript.Shell").Run HLink

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
ok that is great , just a side question in access you can using macros , setwarnings to yay or nay. can you do this in vb6 so when you open docs you dont get asked with q's like this could be unsafe ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top