Excel prompts for VBApassword after saving workbook under new name and exiting excel

J

John Peach

Can anyone please advise. Excel prompts for VBA Password after saving
workbook under a new name and exiting excel

The issue looks to be being cause by the following code:

Sub LoadCombo(strSQL As String, comboName As Object)
Sheets("Data").Visible = True

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strFile As String
Dim psDrop As Variant
Dim strCon As String
strFile = Workbooks(1).FullName

strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFile _
& ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";"

Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")

cn.Open strCon
rs.Open strSQL, cn

psDrop = rs.GetRows
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing



With comboName
.Clear
.BoundColumn = 1
.List = Application.WorksheetFunction.Transpose(psDrop)
'.ListIndex = -1
.ListIndex = 0
.Value = .List(0)
If comboName.Name <> "cmbSport" And comboName.Name <> "cmbClass"
Then .AddItem "N/A"
End With

Sheets("Data").Visible = xlVeryHidden

End Sub


This is stored in a module and is called from a form to populate a combo

Sub UserForm_Initialize()

Dim strSQL As String

Application.ScreenUpdating = False

'load Standard of Presentation
strSQL = "SELECT code FROM LDCLookUp Where (Category='LDC Presentation
Standard') AND (status='Active') ORDER BY [Order]"
LoadCombo strSQL, cmbStdOfPresentation

................
LDCLookUp is a range on the sheet called Data
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top