View Single Post
 
Old 06-09-2015, 09:54 AM
niton niton is offline Windows 7 64bit Office 2010 64bit
Competent Performer
 
Join Date: Jul 2012
Posts: 102
niton is on a distinguished road
Default

It might be quite disturbing to have the file open up every time you send mail.

This goes into the ThisOutlookSession module. It runs when Outlook is started.

Code:
 
Private Sub Application_Startup()
 
    Dim oXLApp As Object
    Dim oXLwb As Object
    Dim oXLws As Object
 
    On Error Resume Next
    Set oXLApp = GetObject(, "Excel.Application")
    If Err.Number <> 0 Then
        Set oXLApp = CreateObject("Excel.Application")
    End If
    On Error GoTo 0
 
    oXLApp.Visible = True
    Set oXLwb = oXLApp.Workbooks.Open("h:\Test\test.xlsx")
    Set oXLws = oXLwb.Sheets("Sheet2")
    oXLws.Select
 
ExitRoutine:
    Set oXLws = Nothing
    Set oXLwb = Nothing
    Set oXLApp = Nothing
 
End Sub
Reply With Quote