Reputation: 347
I am trying to open an existing excel sheet from outlook. I can see the workbook open and then it imediately closes again. I have the Excel.Application set to visible. Any ideas? Here is the code.
Function openNewForm(toDoSubject)
MsgBox ("Called")
Dim xlApp As Object
Dim sourceWB As Workbook
Dim sourceSH As Worksheet
Set xlApp = CreateObject("Excel.Application")
With xlApp
.Visible = True
.EnableEvents = False
End With
strFile = "C:\Users\Peter\Documents\ASI\OrderSystem\NewOrderSheet.xlsm"
Set sourceWB = Workbooks.Open(strFile, , False, , , , , , , True)
Set sourceSH = sourceWB.Worksheets("OrderForm")
sourceWB.Activate
End Function
Again this code is running in outlook. I want to keep the file open once it opens.
Upvotes: 1
Views: 20657
Reputation: 347
I got it figured out. I was opening a different workbook and then closing it before I try to open the second one and that was interfering with it. To fix this I kept the excel app open and reset the workbook object to the new workbook i wanted.
Upvotes: 1