Solved

Open Outlook file via Excel VBA

Posted on 2013-01-11
2
708 Views
Last Modified: 2013-01-11
Hi
Within my custom Excel Ribbon, I want to provide a button which will open an Outlook file (.msg format) - it will need to open this file within Outlook.
(This Outlook file will be an email which will provide them help with some aspects of the Ribbon.)

How to I modify my file>open VBA code to tell Excel that this is an Outlook-type file which is being opened (and it neds to open in Outlook and not Excel)?

Thanks a lot
Fergal
0
Comment
Question by:fjkilken
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Accepted Solution

by:
terencino earned 500 total points
ID: 38766527
Hi Fergal, what about:
ActiveWorkbook.FollowHyperlink Address:="full_path_to_MSG_file"

Open in new window

It is quite simple although you need to supress all the hysterical security messages!
...Terry
0
 

Author Closing Comment

by:fjkilken
ID: 38766562
thanks - that's an option alright - just a bit messy with all the dialog boxes
Meantime, I found a solution which uses a function to Shell the appropriate application which seems to work ok

Public Function OpenWithShell(ByVal strFilePath As String) As Boolean
'Author       : Ken Puls
'Macro Purpose: To open any file in the appropriate application
    'Test for file existence to avoid Windows error message
    If Not Dir(strFilePath) = vbNullString Then
        'Open the file
        Shell ("RunDLL32.EXE shell32.dll,ShellExec_RunDLL " & strFilePath)
        OpenWithShell = True
    End If
End Function

Sub OpenFileExample()
'Author       : Ken Puls
'Macro Purpose: To demonstrate the use of the OpenWithShell function
    Dim strFullFileName As String
   
    'Set path to file
    strFullFileName = "C:\My Documents\Some Outlook Message.msg"
   
    'Check if file opened
    If OpenWithShell(strFullFileName) = False Then _
        MsgBox ("File not opened!")
End Sub
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question