oglezsa
04-16-2010, 09:45 AM
Hi there!!!...I use Word to create a Document based on a template via userform and the information from the userform
to an Excel spreadsheet. Everything works fine on that side, problem is when i want to open the excel
file, a msg comes up stating that i can only view the file in ready-only mode,
this is because the Excel process doesn't terminate. The solution is, I have to go into the process manager
and end the Excel process manualy, then I can run Excel again and have full access to the file. My question is how can
I terminate excel with VBA? here is what i have
Option Explicit
Public appXL As Excel.Application
Public xlFile As Excel.Workbook
On the userform_Initialize
Set appXL = CreateObject("Excel.Application")
Set xlFile = appXL.Workbooks.Open _
(FileName:="C:\Documents and Settings\oog1814\Desktop\Test.xls")
...
On THE EXCEL PART OF THE BUTTON CLICK
appXL.Visible = True
xlFile.Worksheets("Sheet1").Range("A2").Select
Range("a65536").End(xlUp).Offset(1, 0).Select
ActiveCell.Select
If ActiveCell = "" Then
ActiveCell.Value = TextBox22.Text
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.Value = TextBox1.Text
ActiveCell.Offset(0, 1).Range("A1").Select
End If
ActiveWorkbook.Save
'appXL.Visible = True
xlFile.Close True
Set xlFile = Nothing
appXL.Quit
Set appXL = Nothing
Thanks for all your help!!!
to an Excel spreadsheet. Everything works fine on that side, problem is when i want to open the excel
file, a msg comes up stating that i can only view the file in ready-only mode,
this is because the Excel process doesn't terminate. The solution is, I have to go into the process manager
and end the Excel process manualy, then I can run Excel again and have full access to the file. My question is how can
I terminate excel with VBA? here is what i have
Option Explicit
Public appXL As Excel.Application
Public xlFile As Excel.Workbook
On the userform_Initialize
Set appXL = CreateObject("Excel.Application")
Set xlFile = appXL.Workbooks.Open _
(FileName:="C:\Documents and Settings\oog1814\Desktop\Test.xls")
...
On THE EXCEL PART OF THE BUTTON CLICK
appXL.Visible = True
xlFile.Worksheets("Sheet1").Range("A2").Select
Range("a65536").End(xlUp).Offset(1, 0).Select
ActiveCell.Select
If ActiveCell = "" Then
ActiveCell.Value = TextBox22.Text
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.Value = TextBox1.Text
ActiveCell.Offset(0, 1).Range("A1").Select
End If
ActiveWorkbook.Save
'appXL.Visible = True
xlFile.Close True
Set xlFile = Nothing
appXL.Quit
Set appXL = Nothing
Thanks for all your help!!!