ScotWW
09-23-2017, 10:30 PM
Hi,
I'm writing to and reading from excel with a thrown together file with the structure below.
Each time I call a function with the same structure, a new instance of excel is created. I would like to neatly close off the new instances of excel when i close the workbook i've been working in.
Is there a one line modification I can make to the bottom of the code to not only close the workbook but the additional instance of excel opened? Thank you
'save project data to the configFile for later use
Private Sub saveProjectTextBoxes()
Dim myexcel As Object
Dim myWB As Object
Set myexcel = CreateObject("Excel.Application")
Set myWB = myexcel.Workbooks.Open(ActiveDocument.Path & "/ConfigFile.xlsm")
myexcel.Visible = True
myWB.sheets("Singular TextBoxes").Cells(7, 6) = "Row7,Col6"
txtReplyDays.Text = myWB.sheets("Singular TextBoxes").Cells(3, 4)
myWB.Save
myWB.Close False
Set myexcel = Nothing
Set myWB = Nothing
End Sub
I'm writing to and reading from excel with a thrown together file with the structure below.
Each time I call a function with the same structure, a new instance of excel is created. I would like to neatly close off the new instances of excel when i close the workbook i've been working in.
Is there a one line modification I can make to the bottom of the code to not only close the workbook but the additional instance of excel opened? Thank you
'save project data to the configFile for later use
Private Sub saveProjectTextBoxes()
Dim myexcel As Object
Dim myWB As Object
Set myexcel = CreateObject("Excel.Application")
Set myWB = myexcel.Workbooks.Open(ActiveDocument.Path & "/ConfigFile.xlsm")
myexcel.Visible = True
myWB.sheets("Singular TextBoxes").Cells(7, 6) = "Row7,Col6"
txtReplyDays.Text = myWB.sheets("Singular TextBoxes").Cells(3, 4)
myWB.Save
myWB.Close False
Set myexcel = Nothing
Set myWB = Nothing
End Sub