Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50151

VBA SET Command to Open Workbook is Generating Errors

$
0
0
Hi all, hoping someone can help with this:
Using the Set command (xl2003) to open a Shared Workbook, (or re-open if already in use, as it usually is, being a Shared file and all), to grab some data for my project. The code shown below works fine, [both WITH and WITHOUT the shared file already being opened in my session, ...however, when other users run the same code, it errors out, complaining that the file is already open, and that you can not have (2) instances of the same file open at the same name.
With DisplayAlerts being False, the warning about re-opening a file already open should be overridden, and the file should close, and re-open without issue, as it does on my machine. (Users in question have same admin privileges to the directory as I do).
Anyway, I am stumped, here's the section of code giving me grief. Note: it is the "Set dbWB3 = Workbooks.Open(dbFPath2 & "\" & dbFName2)" line that it errors on. If anything jumps out, please advise!
Code:

Sub DOWNsyncDBs()
    On Error GoTo SyncErrorDBs:
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
   
    dbFName = "xDATABASE.xls"                                   
    dbFPath = "D:\DATA\!!DMK\xDATA_STORAGE\DRIVER MANAGEMENT"   
    dbFName2 = "DMK Load & Capacity Boards.xls"                 
    dbFPath2 = "D:\DATA\!!DMK\GROUP"                           

    Set dbWB1 = ActiveWorkbook
    Set dbWS1 = dbWB1.Sheets("Active Loads")                     
    Set dbWS3 = dbWB1.Sheets("Driver DB")                       
   
    Set dbWB2 = Workbooks.Open(dbFPath & "\" & dbFName)         
    Set dbWS4 = dbWB2.Sheets("Driver Database")   
    Set dbWB3 = Workbooks.Open(dbFPath2 & "\" & dbFName2)       
    Set dbWS2 = dbWB3.Sheets("Available Loads")                 
   
    dbWS1.Range("pdbLOADS") = dbWS2.Range("aLOADS").Value       
    dbWS4.Range("aDATABASE").Copy Destination:=dbWS3.Range("pdbDATABASE")
    dbWS4.Activate
    ActiveWorkbook.Close
    ThisWorkbook.Activate
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
Exit Sub
SyncErrorDBs:
    ThisWorkbook.Activate
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
MsgBox "Please report mini-sub: SyncErrorDBs has been called"
End Sub


Viewing all articles
Browse latest Browse all 50151

Trending Articles