I can open a workbook using Excel VBA but cannot close it manually... it's as if the VBA code has a grip on it.
How can I open the workbook in such a fashion that a user can close it at will?
Workbooks.Open (wksHidden.Range("A1").Offset(intCounter + 1, 1))
Private Sub cmdOpen_Click()
If lstWorkbooks.ListIndex = -1 Then Exit Sub
Dim intCounter As Integer
For intCounter = 0 To lstWorkbooks.listCount - 1
If lstWorkbooks.Selected(intCounter) Then
Exit For
End If
Next
Workbooks.Open (wksHidden.Range("A1").Offset(intCounter + 1, 1))
End Sub
Add this line at the top of the code module:
Dim MyWb As Workbook
Then use this line to open a file:
Set MyWb = Workbooks.Open("C:\Users\User Name\Documents\Test2")
And this line to close it:
MyWb.Close