VBOffice

Open Excel File from within Outlook

Open frequently used files with a single click directly from Outlook.

Last modified: 2015/08/01 | Accessed: 79.566  | #84
◀ Previous sample Next sample ▶
ReplyAll ReplyAll
ReplyAll alerts you before unintentionally replying all, or if you are a confidential BCC recipient of the e-mail.

Do you frequently want to look at a certain file, an Excel workbbok for instance? This example demonstrates how to open the file via VBA from within Outlook.

You just need to adjust the value of the 'File' variable to point to the Excel workbook.


tip  How to add macros to Outlook
Public Sub OpenMyExcelFile()
  Dim File$
  Dim Xl As Object ' Excel.Application
  Dim Wb As Object ' Excel.Workbook
  Dim Ws As Object ' Excel.Worksheet
  Dim Rn as Object ' Excel.Range

  File = "c:\file.xls"

  On Error Resume Next
  Set Xl = GetObject(, "excel.application")
  On Error GoTo 0
  If Xl Is Nothing Then Set Xl = New Excel.Application
  Set Wb = Xl.Workbooks.Open(File)
  Set Ws = Wb.Sheets(1)
  Ws.Activate
  Set Rn = Ws.Range("a1")
  Rn.Activate
  Xl.Visible = True
End Sub
Reporter Reporter
VBOffice Reporter is an easy to use tool for data analysis and reporting in Outlook. A single click, for instance, allows you to see the number of hours planned for meetings the next month.
email  Send a message