Google Groups Home
Help | Sign in
Open an attachment in a new window using its native application
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Tony29  
View profile
 More options May 24, 6:49 am
Newsgroups: microsoft.public.outlook.program_vba
From: Tony29 <To...@bigpond.com.au>
Date: Sat, 24 May 2008 03:49:00 -0700
Subject: Open an attachment in a new window using its native application
I have VBA code that loops through the attachments of an email item.  For
each attachment that is clearly a document (eg. .doc, .xls, .pdf, etc) I want
to open that document in a separate window using it's native application.  
The effect is just like the user double-clicking on the normal attachment
icon when reading an email in a normal email window.  

I'm hoping this is not complicated by needing to know what application is
the native application and creating the relevant object ... etc.

In Access I can use ...
       Application.FollowHyperlink stFile, , True
 ... but there doesn't seem to have be a similar meethod in Outlook

Tony


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
JP  
View profile
 More options May 25, 9:21 am
Newsgroups: microsoft.public.outlook.program_vba
From: JP <jp2...@earthlink.net>
Date: Sun, 25 May 2008 06:21:27 -0700 (PDT)
Local: Sun, May 25 2008 9:21 am
Subject: Re: Open an attachment in a new window using its native application
One way is to use a Select Case statement to check the last three
digits of the filename and open the appropriate program. Of course you
would need to save the file first, using the SaveAsFile Method on each
member of the Attachments Collection. Here's some air code:

Select Case Right$(Filename, 3)
Case "doc"
Set WordApp = CreateObject("Word.Application")
WordApp.Open Filename
Case "xls"
Set XLApp = CreateObject("Word.Application")
XLApp.Open Filename
End Select

' delete the file after finished
On Error Resume Next
Kill Filename
On Error Goto 0

HTH,
JP

On May 24, 6:49 am, Tony29 <To...@bigpond.com.au> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sue Mosher [MVP-Outlook]  
View profile
 More options May 25, 9:51 am
Newsgroups: microsoft.public.outlook.program_vba
From: "Sue Mosher [MVP-Outlook]" <sue...@outlookcode.com>
Date: Sun, 25 May 2008 09:51:10 -0400
Local: Sun, May 25 2008 9:51 am
Subject: Re: Open an attachment in a new window using its native application
The generic approach is to use Windows Script Host:

     Set Myshell = CreateObject("WScript.Shell") 'Windows Scripting Host Object
     Myshell.Run "C:\some file name.ext"

You must save the attachment to the local file system first, of course, as JP noted.
--
Sue Mosher, Outlook MVP
   Author of Microsoft Outlook 2007 Programming:
     Jumpstart for Power Users and Administrators
    http://www.outlookcode.com/article.aspx?id=54


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google