jmthompson
Well-known Member
- Joined
- Mar 31, 2008
- Messages
- 966
Good morning,
Technically this is an Outlook macro I've created to run each morning when I launch Outlook. I had it working perfectly, but my company moved me to Office 2010 and lost my Outlook macros. I am not stymied by an issue that I know I had and solved previously, but I am not as smart today, as I was then.
This macro identifies today's day, opens an Excel workbook, performs vlookup to find the date and return a value. If the date is found. it generates a message box with that value. Then it closes Excel. This is where my problem is. It closes excel, but it's leaving a process open. When I later try to use an Excel-based add-in, the open process is interfering. I've spent the morning with Professor Google and cannot figure this out. Ideas?
Technically this is an Outlook macro I've created to run each morning when I launch Outlook. I had it working perfectly, but my company moved me to Office 2010 and lost my Outlook macros. I am not stymied by an issue that I know I had and solved previously, but I am not as smart today, as I was then.
This macro identifies today's day, opens an Excel workbook, performs vlookup to find the date and return a value. If the date is found. it generates a message box with that value. Then it closes Excel. This is where my problem is. It closes excel, but it's leaving a process open. When I later try to use an Excel-based add-in, the open process is interfering. I've spent the morning with Professor Google and cannot figure this out. Ideas?
Code:
Private Sub Application_Startup()
Dim myDate As Date
Dim myPrompt As String
myDate = Format(Now(), "mm/dd/yyyy")
Dim xlApp As Excel.Application
Dim myWB As Excel.Workbook
Set xlApp = CreateObject("Excel.Application")
xlApp.Application.Visible = False
Set myWB = xlApp.Workbooks.Open("C:\Users\JThomps2\Desktop\ClosingDays.xls")
On Error GoTo Errorhandler
myPrompt = Excel.Application.VLookup(CDbl(myDate), xlApp.Worksheets("Sheet1").Range("A:B"), 2, False)
MsgBox ("Closing Day " & myPrompt)
Errorhandler:
Excel.Application.Quit
Set xlApp = Nothing
End Sub