Results 1 to 2 of 2
  1. #1
    theoneandonlysmith is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Posts
    2

    Bypass "Data Link Properties"; Changing connection path w/ VBA

    I have a procedure I used with Office 2003 to change connection paths of a template Excel file to the current MDB before refreshing. Now, with 2010, a "Data Link Properties" window pops up and stops all automation. How do I bypass this window? Set oxl = CreateObject("Excel.Application") oxl.Visible = True oxl.DisplayAlerts = False oxl.Workbooks.Open Template For Each ws In oxl.Workbooks(Template).Worksheets For Each lo In ws.ListObjects If lo.SourceType = 3 Then oldmdb = Mid(lo.QueryTable.Connection, _ InStr(1, lo.QueryTable.Connection, "Data Source=") + 12, _ InStr(InStr(1, lo.QueryTable.Connection, "Data Source="), _ lo.QueryTable.Connection, ";") _ - (InStr(1, lo.QueryTable.Connection, "Data Source=") + 12)) lo.QueryTable.Connection = Replace(lo.QueryTable.Connection, _ oldmdb, newPath & "\" & newmdb, , , 1) lo.QueryTable.SourceDataFile = Replace(lo.QueryTable.SourceDataFile, _ oldmdb, newPath & "\" & newmdb) lo.QueryTable.textfileparsetype = 2 lo.QueryTable.Refresh False 'Displays Data Link Properties window lo.QueryTable.Delete End If Next lo Next ws

  2. #2
    theoneandonlysmith is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Posts
    2
    Ok... I figured it out. Because the MDB running the code was also the same MDB containing the data, Excel had trouble sharing the connection. I had to force the connection mode to "Share Deny None". The following is how I did it. oldmdb = Mid(lo.QueryTable.Connection, InStr(1, lo.QueryTable.Connection, "Data Source=") + 12, InStr(InStr(1, lo.QueryTable.Connection, "Data Source="), lo.QueryTable.Connection, ";") - (InStr(1, lo.QueryTable.Connection, "Data Source=") + 12)) rfmode = Mid(lo.QueryTable.Connection, InStr(1, lo.QueryTable.Connection, ";Mode="), InStr(InStr(1, lo.QueryTable.Connection, ";Mode=") + 1, lo.QueryTable.Connection, ";") - (InStr(1, lo.QueryTable.Connection, ";Mode="))) lo.QueryTable.Connection = Replace(Replace(lo.QueryTable.Connection, oldmdb, newloc & "\" & newmdb, , , 1), rfmode, ";Mode=Share Deny None") lo.QueryTable.SourceDataFile = Replace(lo.QueryTable.SourceDataFile, oldmdb, newloc & "\" & newmdb) lo.QueryTable.Refresh False lo.QueryTable.Delete

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Error: Could not use "PATH"; file is already in use
    By avarusbrightfyre in forum Access
    Replies: 4
    Last Post: 06-29-2012, 05:43 PM
  2. Replies: 1
    Last Post: 04-30-2012, 10:09 AM
  3. Replies: 7
    Last Post: 01-29-2012, 07:44 AM
  4. Replies: 3
    Last Post: 04-10-2010, 10:22 AM
  5. Relocating objects via "Left" properties value
    By Ripcut in forum Programming
    Replies: 0
    Last Post: 08-01-2008, 06:40 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums