Alan McGowan
Senior Member
- Outlook version
- Outlook 2013 64 bit
- Email Account
- Exchange Server
I have an Outlook userform that displays data retrieved from an Excel spreadsheet. The userform uses the following code to pull and display the data:
When I close the userform a msgbox type popup appears saying out "Microsoft Excel has Stopped Working". Any ideas what could be causing this problem
Code:
Private Sub UserForm_Initialize()
Me.Top = Application.ActiveWindow.Top
Me.Left = Application.ActiveWindow.Left
Dim xlApp As Object
Dim xlWB As Object
Dim xlWS As Object
Dim i As Long
Set xlApp = CreateObject("Excel.Application")
'Open the spreadsheet to get data
Set xlWB = xlApp.Workbooks.Open("C:\filemail\fm_settings.xlsm")
Set xlWS = xlWB.Worksheets(1)
TextBox2.Value = xlWS.Range("G5")
TextBox3.Value = xlWS.Range("G3")
'Clean up
Set xlWS = Nothing
Set xlWB = Nothing
xlApp.Quit
Set xlApp = Nothing
lbl_Exit:
Exit Sub
End Sub
When I close the userform a msgbox type popup appears saying out "Microsoft Excel has Stopped Working". Any ideas what could be causing this problem