ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel prompts for VBApassword after saving workbook under new name and exiting excel (https://www.excelbanter.com/excel-programming/443748-excel-prompts-vbapassword-after-saving-workbook-under-new-name-exiting-excel.html)

John Peach[_2_]

Excel prompts for VBApassword after saving workbook under new name and exiting excel
 
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





All times are GMT +1. The time now is 05:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com