Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBAPassword Prompt while closing Excel

Tags:

excel

vba

I've got code in a project to read data from a Sheet into a recordset. The VBA code is password protected.
For testing I simplified the code, as shown below:

Option Explicit

Sub sTest()
    Dim dbtmp As DAO.Database

    Set dbtmp = OpenDatabase(Application.ActiveWorkbook.FullName, False, True, _
      "Excel 8.0;HDR=Yes")

    dbtmp.Close
    Set dbtmp = Nothing
End Sub

Whenever I run this code from a Userform, after closing excel, I get prompted for the VBAProject password. Depending on the, I guess, number of modules in the workbook, I've got to cancel, at least, twice.

I've been breaking my head over this for the last week, read every post on the net I could find, but didn't find a solution yet.

like image 710
Stefan Avatar asked Jun 06 '14 11:06

Stefan


2 Answers

As stated by Miqi180, this issue occurs when references to the workbook are not properly cleared; see Microsoft Knowledge Database

It could also occur when Office AddIns are installed. There were/are some known issues:

  • Acrobat PDFMaker COM Addin
    • Fixed in Acrobat 11.0.1
  • Dropbox
    • Not yet fixed; workaround
  • Other Addin?
like image 199
R. Oosterholt Avatar answered Sep 21 '22 17:09

R. Oosterholt


Uncheck 'OLE Automation' in the References window:

enter image description here

like image 20
Tens Avatar answered Sep 18 '22 17:09

Tens