I imported some data from an MDB file while working at home.
created a macro to that effect. and it works fine at my home PC.
but when i try t execute this macro on another PC or work place, then it gives error #13. i dont understand why. something is wrong with the code. i think it is the "WITH" code for query tables connection giving error. can anyone debug this for me please. posting the whole code below.
Sub data1()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim filename1 As Variant
Sheets("DESIGNDATA").Select
If Range("a1") <> "" Then
Range("A1:D4000").Select
Selection.ClearContents
Selection.QueryTable.Delete
Sheets("towers").Select
End If
filename1 = Application.GetOpenFilename( _
filefilter:="MS Access Database, *.mdb", _
Title:="Select Your MDB file")
If filename1 = False Then
MsgBox "You Have Cancelled"
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Exit Sub
End If
Sheets("towers").Select
With Sheets("DESIGNDATA").QueryTables.Add(Connection:=Array(Array( _
"ODBC;DSN=MS Access Database;DBQ=" & filename1 & ";DefaultDir=" & filename1 & ";DriverI" _
), Array("d=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;")), _
Destination:=Sheets("DESIGNDATA").Range("A1"))
.CommandText = Array( _
"SELECT `Concrete Design 1 - Column Summary Data - Indian IS 456-2000`.Story, `Concrete Design 1 - Column Summary Data - Indian IS 456-2000`.ColLine, `Concrete Design 1 - Column Summary Data - Indian I" _
, _
"S 456-2000`.SecID, `Concrete Design 1 - Column Summary Da" _
, _
"ta - Indian IS 456-2000`.As" & Chr(13) & "" & Chr(10) & "FROM `" & filename1 & "`.`Concrete Design 1 - Column Summary Data - Indian IS 456-2000` `Concrete Design 1 - Column Summary Data - Indi" _
, "an IS 456-2000`")
.Name = "Query from MS Access Database"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
Application.CutCopyMode = False
Application.ScreenUpdating = True
Announcement = MsgBox("ETABS Data Imported Successfully", , "Data Transfer Successful")
Application.Calculation = xlCalculationAutomatic
End Sub
THIS WORKS AT HOME. BUT NOT AT MY WORKPLACE IN OFFICE.
MIGHT I ADD. I HAVE MS ACCESS INSTALLED AT HOME. WHILE NO MS ACCESS INSTALLED AT MY WORK PLACE.
do help someeone.
Bookmarks