troubleshooting Question

Creating my first DB connection in VBA, Excel 2007

Avatar of curiouswebster
curiouswebsterFlag for United States of America asked on
Microsoft OfficeMicrosoft ExcelVB Script
7 Comments1 Solution303 ViewsLast Modified:
If this code throws no error, does that mean it's opening a connection? If so, to what?

It stops nicely at a breakpoint and exits the function gracefully.


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    MsgBox "combo change to WS2"
    Dim Myconnection As Connection
    Dim Myrecordset As Recordset
    Dim MyWorkbook As String

    Set Myconnection = New Connection
    Set Myrecordset = New Recordset
 
    'Identify the workbook you are referencing
    MyWorkbook = Application.ThisWorkbook.FullName

    'Open connection to the workbook
    Myconnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                  "Data Source=" & MyWorkbook & ";" & _
                  "Extended Properties=Excel 8.0;" & _
                  "Persist Security Info=False"



End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros