I have an access VBA program that opens an excel file in order to retrieve some data.
Private Function getSampleDescription() As Boolean
' Assign the Excel Object
If gfcHandleErrors Then On Error GoTo errorExit:
getSampleDescription = True
Dim excelapp As Object
Set excelapp = CreateObject("excel.application")
' Assign the workbook
Dim wb As Object
Set wb = excelapp.Workbooks.Open(fileName:=fileName, ReadOnly:=True, Password:=sampleFilePassword)
'Assign the sheet
Dim sh As Object
Set sh = wb.worksheets("Sample Description")
It had been working fine but recently (not sure why), I get an excel prompt asking Save, Don't Save or Cancel.
This happens immediately after the Workbooks.Open statement. If I choose Save I get a prompt to save the excel table to Copy of ExcelFilename. Once I save the code then proceeds normally. If I choose Don't Save the code just proceeds normally. If I choose Cancel the prompt reappears; choosing Cancel a second time aborts the code.
Any idea what is provoking this? Could it be password protection on my workbook or worksheets. How can I make it stop!
Access and Excel 2010 versions operating on Windows 7.
Thanks for any help ...
excelapp.DisplayAlerts = False
before opening the workbook. – Tim Williams