I have this macro that is password protected and shows a form. Recently I added code to import data from excel and every time I close it asks me for a password - I can cancel through it but I'd like to make it go away, I see no plausible reason why it would come.
I've separated out the few lines that causes this problem
Sub a()
UserForm1.Show
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0" & _
";Data Source=" & "C:\Book1.xls" & _
";Extended Properties='Excel 8.0; IMEX=1'" & _
";Persist Security Info=False"
Set objRSGlobal = CreateObject("ADODB.Recordset")
objRSGlobal.Open "select * from [Sheet1$]", strConnString
objRSGlobal.Close
Set objRSGlobal = Nothing
End Sub
This goes into Module1. I have a blank form called UserForm1. I lock the code (for viewing as well) using a password and save everything in Book1.xls.
Now I open the file, do an Alt+F8 to run the macro, close the form and then close the file the password prompt comes up. I can't understand why it comes up and how to make it go away.
Thanks in advance!!
Note - for the record, this also happens if I just show the form and do an Import Data via the UI (Data > Import External Data > Import Data)
- Update - it looks like its happening only when I import from the same file I have open.