K
Kevin
I have a macro in my personal.xls attached to a toolbar that opens a userform
and displays various files in a listbox along with a date in a textbox. I can
select a file and date and then run a command (code below) button to open
that file. It works the first time but when I open the userform the next time
and select a file I get the following error
"Could not complete the operation due to error 800a01a8". I close the
userform and it works the next time.
Basically it does not work after each time I press the command button - i
get error above, close the userform, open it again, it them works next time
and we start the loop again
What I can see is when it does not work the command button looks like it has
focus but also the listbox has the file highlighted I opened the previous
time. When it does works the command button has no focus and nothing is
highlighted in the listbox and the cursor is flashing in the text box
any ideas what problem is and how to fix
Private Sub CommandButton1_Click()
Dim wbOpenFile As Workbook
ActiveSheet.Calculate
Set wbOpenFile = ActiveWorkbook
Dim PLpath As String
PLpath = Range("PLpath")
Workbooks.Open Filename:=PLpath
With UserForm1
.Hide
End With
wbOpenFile.Close savechanges = False
and displays various files in a listbox along with a date in a textbox. I can
select a file and date and then run a command (code below) button to open
that file. It works the first time but when I open the userform the next time
and select a file I get the following error
"Could not complete the operation due to error 800a01a8". I close the
userform and it works the next time.
Basically it does not work after each time I press the command button - i
get error above, close the userform, open it again, it them works next time
and we start the loop again
What I can see is when it does not work the command button looks like it has
focus but also the listbox has the file highlighted I opened the previous
time. When it does works the command button has no focus and nothing is
highlighted in the listbox and the cursor is flashing in the text box
any ideas what problem is and how to fix
Private Sub CommandButton1_Click()
Dim wbOpenFile As Workbook
ActiveSheet.Calculate
Set wbOpenFile = ActiveWorkbook
Dim PLpath As String
PLpath = Range("PLpath")
Workbooks.Open Filename:=PLpath
With UserForm1
.Hide
End With
wbOpenFile.Close savechanges = False