![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]() Hello there, New to VBA in Outlook, and have a quick question; There are a number of emails that drop into a joint inbox in my department. These emails contain excel attachments. I can write some VBA code to deal with the attachment in excel, but would like to totally automate the process by writing some VB in Outlook to open up the attachment based on the Email Subject line?? Would be grateful for a few lines to get me started. Thanks in advance Whelan |
#2
|
|||
|
|||
![]()
In order to do any manipulation of an Attachment object you need to save it
to the file system. You can use the SaveAs method to do that. Once you have saved an attachment then manipulating it in code depends on what type of file the attachment is. If it's a Word file for example you'd automate Word to open it. Take a look at the code at http://www.slovaktech.com/code_sampl...ripAttachments for an example of working with attachments in code. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Whelan" wrote in message ... Hello there, New to VBA in Outlook, and have a quick question; There are a number of emails that drop into a joint inbox in my department. These emails contain excel attachments. I can write some VBA code to deal with the attachment in excel, but would like to totally automate the process by writing some VB in Outlook to open up the attachment based on the Email Subject line?? Would be grateful for a few lines to get me started. Thanks in advance Whelan |
#3
|
|||
|
|||
![]()
The short version of how to do this:
- call Attachment.SaveAs - output to a directory of your choice - use the ShellExecute Win32API function to run the file as if you double-clicked it Here's an example: 'Code for the General Declarations section of your module Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _ (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String _ , ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long Public Const conSwNormal = 1 'Sample calling code ShellExecute 0, "open", "C:\Temp\Sheet1.xls", vbNullString, "C:\Temp", conSwNormal I've written an MSDN article as well that details a similar approach for a larger solution if you want to see an example in context: Office Developer Center: Viewing Multiple Picture Attachments in Outlook 2003: http://msdn.microsoft.com/office/def...PictAttach.asp -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "Whelan" wrote: Hello there, New to VBA in Outlook, and have a quick question; There are a number of emails that drop into a joint inbox in my department. These emails contain excel attachments. I can write some VBA code to deal with the attachment in excel, but would like to totally automate the process by writing some VB in Outlook to open up the attachment based on the Email Subject line?? Would be grateful for a few lines to get me started. Thanks in advance Whelan |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Open appointments from VBA Form? | Sangeeta | Outlook - Calandaring | 0 | June 20th 06 09:21 PM |
How to open Public Folders 'Contact Form' using VBA | mmattson | Outlook and VBA | 1 | May 17th 06 11:06 PM |
VBA Code not running until editor is open | gamename | Outlook and VBA | 0 | May 17th 06 06:42 PM |
PDF Attatchments Won't Open | jimbo 6 | Outlook Express | 7 | March 29th 06 09:09 PM |
possible to open two profiles at the same time with VBA??? | carteriii | Outlook and VBA | 2 | February 8th 06 05:47 PM |