Although I used to be pretty advanced using VBA many moons ago, apparently that guy has left the building.
I just recovered some very large commodity and equity data sets I had in excel files from years ago. I have compiled them all together into one file and am trying to upload the data to my Azure SQL server. I cannot find ANYTHING anywhere on how to load data TO Azure, but I find many articles on loading FROM Azure.
Inside excel you can only create a connection to Azure SQL to IMPORT data into excel, one way street, no way to make a connection you can load from.
Any help appreciated. I can always use the old CSV's, read them in using c# in my web app, but I can update the data to current each week in this one file and I'd prefer to write the whole routine in VBA to get the data, check it, and load it to Azure.
Note: Yes, I know how to use ADODB connections but I cant find any drivers specific to using Azure SQL
Further update:
Using the following and I've tried 2 dozen variations, produces this error each time. And I installed the Sql Native Client Driver #12
Here is the function with the Driver, which I believ eis the issue, or the permissioning, because the azure sql db exists. This is the connection string from the portal
Public Function ExportExcelDataToAzureDb(wsSource As Worksheet) As Boolean
'I am using Activex Data Object 2.8 reference
Dim connectionString As String
Dim oConn As ADODB.Connection
Dim record As ADODB.Recordset
Dim cmd As ADODB.Command
connectionString = "Driver={SQL Server Native Client 12.0};Server=tcp:myazuresqlserver.database.windows.net,1433;Initial Catalog=myappdb;Persist Security Info=False;User ID=myuser;Password={mypass};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
Set oConn = New ADODB.Connection
oConn.connectionString = connectionString
oConn.Open
'load the data
ExportExcelDataToAzureDb = True
End Function
Obviously, I have substituted for the server, db, user and password
After a LOT of searching for various connection strings examples AND about 100 different tests of string variations.
Here is the proper connection string format to use with Excel VBA to import/export data from Azure SQL Database. I am providing my whole function for inserting data, with some parts removed for security concerns.
Option Explicit
Public dbConn As ADODB.Connection
Public adodbRecordSet As ADODB.recordSet
Public rsc As ADODB.recordSet
Public Const AzureDataSource As String = "tcp:yourazuredbservername.database.windows.net,1433"
Public Const AzureDbName As String = "yourazuredbname"
Public Const dbDriverProvider As String = "SQLNCLI11"
'I am using Activex Data Object 2.8 reference, SQL Native Client 11
Public Function ExportExcelDataToAzureDb(wsSource As Worksheet, dataRange As Range) As Boolean
Dim connectionString As String, sql As String
Dim cnt As Integer
Dim cCell As Range
connectionString = "Provider=" & dbDriverProvider & ";" & "Password=yourpassword;User ID=yourusername; " & _
"Initial Catalog=" & AzureDbName & ";" & _
"Data Source=" & AzureDataSource & ";"""
Set dbConn = New ADODB.Connection
Set adodbRecordSet = New ADODB.recordSet
dbConn.connectionString = connectionString
dbConn.Open
' do work here
cnt = 0
With wsSource
For Each cCell In dataRange
sql = "your insert statement here"
adodbRecordSet.Open sql, dbConn, adOpenDynamic, adLockReadOnly, adCmdText
cnt = cnt + 1
Next cCell
End With
'clean up
dbConn.Close
' log count of uploaded data records
Call PrintLog("Records loaded on " & Now & ": " & cnt & " symbol records")
ExportExcelDataToAzureDb = True
End Function
If anyone knows how to get this working with later versions of the ActiveX Data Object or the SQL Native Client Library please post another answer.
After trying many solution, i have come to the conclusion that the most important thing is
using Activex Data Object 2.8 reference, SQL Native Client 11. using the lower version seems to work best
for my connection string i am using what is below format
connection = "Driver={SQL Server Native Client 11.0};" & _
"Server=tcp:YourDataBase.net,1433;" & _
"Database=YourDatabaseName;" & _
"Uid=XXXX;" & _
"Pwd=XXXXXXX;" & _
"Encrypt=yes;Connection Timeout=30;"
Hope this help other people. This was super frustrating for me
Related
I am writing a small application in Excel 2002 and I need to store numbers in some format, it can be a string.
The tables I have a 1:1 relationship and other table is just a table of one column so using access is not necesary and having to have another file is something I'd like to avoid.
So, I want to store it in separate sheets.
However, I like the benefits of SQL for querying and I need it.
I tried using some ADODB connection strings to reach this but I cannot achieve it.
I used the following code:
Dim cn As Object, rs As Object, output As String, sql As String
'---Connecting to the Data Source---
Set cn = CreateObject("ADODB.Connection")
With cn
.Provider = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyExcel.xls;"
.ConnectionString = "Data Source=" & ThisWorkbook.FullName & ";" & "Excel 8.0;HDR=Yes;IMEX=1"
.Open
End With
Also, do I have to use ODBC or should I use OLE DB? I don't know if OLE DB could be used to query in excel files.
Also, is it possible to do inserts with SQL using this ODBC or OlE DB?
I tried different providers in the connection string, and I checked the ADO references to be available.
Also, I get this error:
"Error 3706. The specified provider could not be found. It may not be installed properly."
Connection issue
First, there was an error in your Provider string, it should not contain the part with Data Source=C:\MyExcel.xls; since this is part of the connection string. So it should look like this:
.Provider = "Provider=Microsoft.Jet.OLEDB.4.0;"
.ConnectionString = "Data Source=" & ThisWorkbook.FullName & ";" & "Excel 8.0;HDR=Yes;IMEX=1"
ODBC vs OLEDB
I've never used ODBC, but based on this answer, you can't use it to query an Excel file, so OLEDB is the way to go.
Insert Statement
Once you have a working ADODB connection, insert query should work as hoped. I'm providing an example below that worked for me, but there is a few caveats:
I'm using the ACE.OLEDB.12.0 instead of JET.OLEDB.4.0 with Excel for Microsoft 365 MSO (Version 2112 Build 16.0.14706.20000) 64-bit on Windows 10.
I'd suggest to set Mode=ReadWrite in your connection string to avoid potential writting permission issues (but it might work even without it.).
Regarding the IMEX setting, I was having errors when it was set to IMEX=1, so I switched to IMEX=0 (see related question.
The example
With a workbook named Data.xls with the first sheet named Data and the following data :
Data for copy-paste
I can run the following:
Dim wb As Workbook
Set wb = Workbooks("Data.xls")
Dim ws As Worksheet
Set ws = wb.Worksheets("Data")
'Create connection
Dim conn As Object
Set conn = CreateObject("ADODB.Connection")
With conn
.Provider = "Microsoft.ACE.OLEDB.12.0;"
.ConnectionString = "Data Source=" & wb.FullName & ";" & "Excel 8.0;HDR=Yes;IMEX=0;Mode=ReadWrite;"
.Open
End With
'Compose the INSERT statement.
Dim query As String
Const sep = ", "
query = "INSERT INTO [" & ws.Name & "$] " & _
"(Id, Name, Age) " & _
" VALUES (" & _
4 & sep & _
"'" & "Joe" & "'" & sep & _
40 & _
")"
'Execute the statement.
conn.Execute query, adCmdText
'Close the connection
conn.Close
And it should insert the data as follow:
Should you use ACE or JET?
If JET works for you, you might as well use it. Based on this article , you should also have the 32-bit version of ACE available with Windows 7 to work with Excel 2002 (32-bit), but based on your comment it seems like it's causing some problems.
See also some interesting answer about JET vs ACE.
I have an excel file that contains a series of OLEDB connections leveraged by several pivot tables. I would like to create a VBA function that removes all password from that several connection string as the file is closed(so that the users password will not be persisted). First I thought all I need to do was set the "Save Password" property to false, something like this:
Public Sub RemovePasswordByNamePrefix()
Dim cn As Object
Dim oledbCn As OLEDBConnection
For Each cn In ThisWorkbook.connections
Set oledbCn = cn.OLEDBConnection
oledbCn.SavePassword = False
Next
End Sub
Should work right, on closing the file and reopening it you shouldn't see the password anymore in the connection string. It should not be "Saved":
Wrong, password is still there... It has been "Saved". Not sure what that feature is supposed to do. Maybe there referring to a different password? So, I attempted the big hammer approach, unfortunately it has it's own challenges, and so far I haven't gotten that working.
I'm not quite sure how to do this... Why is this so massively insecure? It persists plaintext passwords every file that contains a connection string of this sort, easily readable by whoever could access that file.
Maybe I could make some sort of Regex to remove just the password from the file? When I do that in the interface my cubes refresh and prompt me for my credentials, (I wonder)would that occur if I did it in VBA, even if the trigger is upon excels closure?
Bottom Line: What is the best way to prevent these passwords from being persisted in the file upon it's closure?
#TomJohnRiddle points out that I should look at modifying the connection string similar to the following question. Initially I was concerned that taking this approach could prompt the user with a login screen after modifying the connection string. However since I don't have any better ideas I gave it a shot, and it seems to work, here's what I've mocked up:
Public Sub RemovePasswordByNamePrefix()
Dim cn As Object
Dim oledbCn As OLEDBConnection
Dim regEx As New RegExp
regEx.Pattern = "Password=[^;]*;"
For Each cn In ThisWorkbook.connections
Set oledbCn = cn.OLEDBConnection
oledbCn.SavePassword = False
oledbCn.connection = regEx.Replace(oledbCn.connection, "")
oledbCn.CommandText = "" 'My app repopulates this after open
Next
End Sub
and it seems to work:
So I think I'll go with this approach, but I'm still open to other suggestions. Would be nice to clear everything and fully reload it, but so far that doesn't appear to be possible.
I'm also concerned with what versions of VBA support the "Regex" references. I would like something that would be Excel 2010+ 32/64 bit compatible. I have yet to test this on any older version(I'm currently running Office 365). I assume it will all work fine, but I've been unpleasantly surprised with these things in the past.
See this on SQL Server authentication Authentication in SQL Server. There it says you can use 100% Windows Authentication or you can use Mixed-Mode (Windows Authentication and passwords). If you really want to banish passwords from connection strings do not install with Mixed Mode Authentication just run 100% Windows Authentication. However, there may be some code already deployed written to use passwords so that may not always be practical.
So, the other way to discipline no passwords is to use
Integrated Security=true;
in your connection strings. This Stack Overflow question on the subject is well visited.
#NigelHeffernan suggests a slightly different approach for how to do this, here's a version without regex's:
Public Sub RemovePasswordByNamePrefix()
Dim cn As Object
Dim oledbCn As OLEDBConnection
Dim stringArray
Dim stringElement As Variant
Dim newStringArray As Variant
For Each cn In ThisWorkbook.connections
Set oledbCn = cn.OLEDBConnection
oledbCn.SavePassword = False
stringArray = Split(oledbCn.connection, ";")
For Each stringElement In stringArray
If Not InStr(stringElement, "Password=") Then
If IsEmpty(newStringArray) Then
newStringArray = Array(stringElement)
Else
ReDim Preserve newStringArray(UBound(newStringArray) + 1)
newStringArray(UBound(newStringArray)) = stringElement
End If
End If
Next
oledbCn.connection = Join(newStringArray, ";")
oledbCn.CommandText = "" 'My app repopulates this after open
Next
End Sub
I'm not sure the benefit of this method(other than a lack of another library reference) and I haven't tested outside of one connection string/one machine yet. My connection strings don't contain the "Extended Properties" field, maybe this approach wouldn't work for that.
It looks like you are using DSNs, which is something that Excel will create if you use the default connection management tools in the GUI. When working with DSNs, the ODBC driver will sometimes put cleartext passwords in to the Registry, even when you don't select "Save Password".
Instead of allowing Excel to manage your connections you would need to manage them yourself. Here is some example code from MS MVP Ben Clothier. You would have to modify the connection string to match your use case. You might be able to copy the details from your existing connections before you remove them.
Public Function InitConnect(UserName As String, Password As String) As Boolean
‘ Description: Should be called in the application’s startup
‘ to ensure that Access has a cached connection
‘ for all other ODBC objects’ use.
On Error GoTo ErrHandler
Dim dbCurrent As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
‘<configuration specific to MySQL ODBC driver>
strConnection = “ODBC;DRIVER={MySQL ODBC 5.1 Driver};” & _
“Server=” & ServerAddress & “;” & _
“Port=” & PortNum & “;” & _
“Option=” & Opt & “;” & _ ‘MySql-specific configuration
“Stmt=;” & _
“Database=” & DbName & “;”
Set dbCurrent = DBEngine(0)(0)
Set qdf = dbCurrent.CreateQueryDef(“”)
With qdf
.Connect = strConnection & _
“Uid=” & UserName & “;” & _
“Pwd=” & Password
.SQL = “SELECT CURRENT_USER();”
Set rst = .OpenRecordset(dbOpenSnapshot, dbSQLPassThrough)
End With
InitConnect = True
ExitProcedure:
On Error Resume Next
Set rst = Nothing
Set qdf = Nothing
Set dbCurrent = Nothing
Exit Function
ErrHandler:
InitConnect = False
MsgBox Err.Description & ” (” & Err.Number & “) encountered”, _
vbOKOnly + vbCritical, “InitConnect”
Resume ExitProcedure
Resume
End Function
NOTE:
This is written for MS Access, not Excel. The concepts are all the same. You might want to try making your front end in Access and then export your views to Excel from Access. This would allow you better control of the link to your back-end and allow you to use SQL in Access to define what you want to export to Excel.
READ THIS:
https://www.microsoft.com/en-us/microsoft-365/blog/2011/04/08/power-tip-improve-the-security-of-database-connections/
I hope someone can help.
I've developed an excel package that updates a .mdb access database through the connection string "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"
The database is shared.
I have a Mitel telephony system that checks the database every 10 seconds or so to check for a new entry.
The database is updated with
Dim q As New ADODB.Command
Dim cn As New ADODB.Connection
Dim SQL As String
SQL = "INSERT INTO tbl1LinkAuths (DateTimeAdded, DateEntered, AddedBy, REG, OrderNo,AccountNumber, CentreNumber, EmailAddress, Callback, "
SQL = SQL & "MakeText, "...............
cn.Open cnDB
q.ActiveConnection = cn
q.CommandText = SQL
'Excecute the above SQL to insert the new job record
q.Execute
Set rs = Nothing
Set cn = Nothing
Dim db As Access.Application
Set db = New Access.Application
db.Application.Visible = False
db.OpenCurrentDatabase "\\kffcis02\VWM Share\TelephonyDB.mdb", False
db.CloseCurrentDatabase
The INSERT statement updates the database fine, but I find I have to open and close the database to get it to update in time.
This package is used heavily by around 5 people at a time, making about 2 entries per minute.
It comes up with the error "file already in use", especially when using excel 2013, a lot of the time. I think this is because I have to open/close the database every time I update.
Does anybody know of a different way I can get the database to update quicker?
I've got the actual database setting to update ADODB every second and the database is shared.
I'm now desperate, as this package has went live. I didn't have any problems during testing because there wasn't as many people using it and none of them were on office 2013.
Wrong driver: Assuming a reference to activex data objects...
dim conn as adodb.connection 'module level variable
const DBNAME = "your name here"
const DBLOC = "Your dir here"
Sub UpdateDb()
dim sql as string
openconnectionroutine
sql = "INSERT INTO tbl1LinkAuths (DateTimeAdded, DateEntered, AddedBy, "
'etc
'if you want to check it worked : otherwise ditch numrecs
dim numrecs as long
conn.execute sql, numrecs
msgbox "You added " & numrecs & " records",vbokonly,"Done"
end sub
sub Openconnectionroutine()
if conn is nothing then set conn = new adodb.connection
if conn.connectionstring = "" then
conn.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=" & DBNAME & ";" & _
"DefaultDir=" & DBLOC & ";" & _
"Uid=Admin;Pwd=;"
end if
if conn.state = adstateopen then
else
conn.Open
end if
End sub
I'm working on an excel application that requires a database back end. My preference is to use SQLite 3 and to make this as seamless and portable as possible for the end user.
Recently I have learned that an Excel 2007 file is simply a zip archive with a xlsm extension. My question is this, can I store my back-end SQLite 3 database in the Zip archive and use ODBC to interact with the database. If so, can anyone point me to some background information, articles, guidance on achieving this objective. Are there any downsides to this approach or a better alternative I should know about.
Thanks for your input.
Some notes. So far, no one has complained that the file does not open. Note that the Excel file is saved before the ADO code is run.
Very hidden:
ThisWorkbook.Worksheets("Courses").Visible = xlVeryHidden
ThisWorkbook.Worksheets("System").Visible = xlVeryHidden
A snippet of code:
Const gCN = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="
<...>
Set rs = CreateObject("ADODB.Recordset")
Set cn = CreateObject("ADODB.Connection")
Set fs = CreateObject("Scripting.FileSystemObject")
scn = gCN & ThisWorkbook.FullName _
& ";Extended Properties=""Excel 8.0;HDR=Yes;"";"
cn.Open scn
''If they do not have an ID, they do not exist.
sSQL = "SELECT ID,FirstName,LastName, " _
& "CourseName,AdditionalText,Format(ExpiryDate,'dd/mm/yyyy') As ExpiryDate " _
& "FROM [Applicants$] WHERE DateCancelled Is Null AND ID Is Not Null " _
& "AND (FirstName Is Null OR LastName Is Null Or CourseName Is Null " _
& "Or ExpiryDate Is Null) " & sWhere
rs.Open sSQL, cn
References:
Excel ADO
Connection strings
Most of the methods available to Jet can be used with Excel
Fundamental Microsoft Jet SQL for Access 2000
Intermediate Microsoft Jet SQL for Access 2000
Advanced Microsoft Jet SQL for Access 2000
Edit re Comments
I did not find the leak particularly bad, but I did not run many iterations, and this is quite a good machine.
The code below uses DAO, which does not cause a memory leak.
'Reference: Microsoft Office 12.0 Access Database Engine Object Library
Dim ws As DAO.Workspace
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim sDb As String
Dim sSQL As String
sDb = ActiveWorkbook.FullName
Set ws = DBEngine.Workspaces(0)
Set db = ws.OpenDatabase(sDb, False, True, "Excel 8.0;HDR=Yes;")
sSQL = "SELECT * FROM [Sheet1$];"
Set rs = db.OpenRecordset(sSQL)
Do While Not rs.EOF
For i = 0 To rs.Fields.Count - 1
Debug.Print rs.Fields(i)
Next
rs.MoveNext
Loop
rs.Close
db.Close
ws.Close
'Release objects from memory.
Set rs = Nothing
Set db = Nothing
Set ws = Nothing
Acknowledgement: http://www.ozgrid.com/forum/showthread.php?t=37398
Here is an alternative.
1) At Open (EVENTs in VBA) unzip from Excel .xlsm, sqlite and dbFile.
2) Process what you .....
3) At save (EVENTs in VBA) the book an then attach the Excel .xlsm ,sqlite , dbFile in Excel .xlsm.
Excel rewrites the file every time it is saved, so your own added file would be deleted.
Furthermore, there is no SQLite driver that can access database files inside of zip archives.
You would have either to ship the database file alongside with the Excel file, or to recreate the database with a list of SQL commands when your application detects that the DB file is missing.
This still requires that some SQLite (ODBC) driver is installed on the user's machine.
The most seamless and portable way to store data in an Excel file is to store it in an Excel sheet, as mentioned by Remou. However, it's possible that the ADO driver will refuse to open the file when it's already open in Excel, so that you have to use Excel functions to access the data.
Try using http://code.google.com/p/pyinex/
this embed the Python interpreter in Excel
Hey all, have been working on designing a new database for work. They have been using Excel for their daily reports and all the data is stored in there, so I decided to have the back-end of the database in Access and the front-end in Excel, so any analytical work can be easily performed once all the data has been imported into Excel.
Now I'm fairly new to VBA, slowly getting used to using it, have written some code to transfer one of the calculated tables from Access to Excel:
Option Explicit
Public Const DataLocation As String = "C:\Documents and Settings\Alice\Desktop\Database\TestDatabase21.accdb"
Sub Market_Update()
Call ImportFromAccessTable(DataLocation, "Final_Table", Worksheets(2).Range("A5"))
End Sub
Sub ImportFromAccessTable(DBFullName As String, TableName As String, TargetRange As Range)
Dim cn As ADODB.Connection, rs As ADODB.Recordset, intColIndex As Integer
Set TargetRange = TargetRange.Cells(1, 1)
' open the database
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & DBFullName & ";"
Set rs = New ADODB.Recordset
With rs
' open the recordset
' .Open TableName, cn, adOpenStatic, adLockOptimistic, adCmdTable
' all records
.Open "SELECT * FROM Final_Table", cn, , , adCmdText
' filter records
For intColIndex = 0 To rs.Fields.count - 1 ' the field names
TargetRange.Offset(0, intColIndex).Value = rs.Fields(intColIndex).Name
Next
TargetRange.Offset(1, 0).CopyFromRecordset rs ' the recordset data
End With
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub
Sub Company_Information()
Dim companyName As String
On Error GoTo gotoError
companyName = Application.InputBox(Prompt:="Enter Company Name", _
Title:="Company Name", Type:=2)
Exit Sub 'Don't execute errorhandler at end of routine
gotoError:
MsgBox "An error has occurred"
End Sub
The above code works fine and pulls up the desired calculated table and places it in the right cells in Excel.
I've got two problems that I'm having trouble with; firstly I have some cell-formatting already done for the cells where the data is going to be pasted into in Excel; I want it to apply the formatting to the values as soon as they are pasted in Excel.
Secondly; I have an add-on for Excel which updates some daily Stock Market values; these values need to be transferred into Access at the end of each working day, to keep the database maintained, I tried some code but have been having some problems with it running.
The code for this part can be seen following:
Sub UPDATE()
Dim cnt As ADODB.Connection
Dim stSQL As String, stCon As String, DataLocation As String
Dim stSQL2 As String
'database path - currently same as this workbook
DataLocation = ThisWorkbook.Path & DataLocation
stCon = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & DataLocation & ";"
'SQL code for GL Insert to Access
stSQL = "INSERT INTO Historical_Stock_Data SELECT * FROM [Portfolio] IN '" _
& ThisWorkbook.FullName & "' 'Excel 8.0;'"
'set connection variable
Set cnt = New ADODB.Connection
'open connection to Access db and run the SQL
With cnt
.Open stCon
.CursorLocation = adUseServer
.Execute (stSQL)
End With
'close connection
cnt.Close
'release object from memory
Set cnt = Nothing
End Sub
I get the following error with this.
Run-time Error '-2147467259 (80004005)'
The Microsoft Jet database engine cannot open the file 'Cocuments and Settings\Alice\Desktop\Database'. It is already opened exclusively by another user or you need permission to view its data.
I'm fairly new to databases, VBA and Access so any help would be greatly appreciated.
Also I have been told that the above method of having an Excel front-end and Access back-end is not recommended but alot of the analysis they conduct is done through Excel, and the charts feature in Excel is much better than Access in my experience atleast; and that is also one of the requirements for this project.
Thank you advance!
Solution to your first problem:
Sorry to be the bearer of bad news, but your entire first module is unnecessary. Instead, try:
Go to Data->Import External Data->Import Data, select your Access file, select your table, and presto! done!
Right-click on your new "External Data Range" to see a number of options, some related to formatting. You can even keep the original cell formatting and just update the values. I do this all the time.
To update the Excel data table later, there is a "External Data Range" toolbar that allows you to refresh it as well as a "refresh all" option to refresh every table in the Excel file. (You can also automate this thru code. It'll take some trial and error, but you're definitely up to the task)
Regarding your second problem
I've never used it, but there is also a "New Web Query" option in there as well. I assume it can be manipulated and updated the same way.
And lastly
Your choice of the Excel front-end and the Access back-end sounds good for your needs. It gets the data to your analysts in a medium they are familiar with (Excel) while keeping the calculations out of the way in Access. Technically, you could try putting all your calculations in Excel, but that might the Excel file much bigger and slower to open.
Do the data entry/updating/reviewing in Access. One of Access' strengths is using forms that allow you to update the tables without any code. Then allow the users to easily export the data to Excel such as by clicking on some command buttons.
Modules: Sample Excel Automation - cell by cell which is slow
Modules: Transferring Records to Excel with Automation
nothing wrong in principle with the excel/access pairing. I'm not familiar with ADO (I use DAO), but your error message seems to be indicating that the path to the datasource is not fully formed; or you already have it opened and hence are locking it.