Good Morning
I have the following recorded Macro, which imports a specific db4 dbf into excel. However the data source C:\db4\PORT\426950\2004 will not remain constant. The last two subfolders will constantly change. I'm trying to have an inputbox change that Data Source without success. I tried to create a variable again without success.
Any help with this would be greatly appreciated.
Sub Testimport()
'
' Testimport Macro
' Macro recorded 4/28/2006 by laxlunn
'
'
Dim [data Source] As string
[data Source] = InputBox("Import Table:", "Importing 1099DBF", "")
With ActiveSheet.QueryTables.Add(Connection:=Array( _
"OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=C:\db4\PORT\426950\2004\;Mode=Share Deny Write;Extended P" _
, _
"roperties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDBatabase Password="""";Jet OLEDB:Engine Type=18;Jet" _
, _
" OLEDBatabase Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database P" _
, _
"assword="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDBon't Copy Locale on Compact=False;" _
, "Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False"), _
Destination:=Range("A1"))
.CommandType = xlCmdTable
.CommandText = Array("A_1099")
.Name = "A_1099"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
'.SourceDataFile = "C:\db4\PORT\426950\2002\A_1099.DBF"
.Refresh BackgroundQuery:=False
End With
I have the following recorded Macro, which imports a specific db4 dbf into excel. However the data source C:\db4\PORT\426950\2004 will not remain constant. The last two subfolders will constantly change. I'm trying to have an inputbox change that Data Source without success. I tried to create a variable again without success.
Any help with this would be greatly appreciated.
Sub Testimport()
'
' Testimport Macro
' Macro recorded 4/28/2006 by laxlunn
'
'
Dim [data Source] As string
[data Source] = InputBox("Import Table:", "Importing 1099DBF", "")
With ActiveSheet.QueryTables.Add(Connection:=Array( _
"OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=C:\db4\PORT\426950\2004\;Mode=Share Deny Write;Extended P" _
, _
"roperties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDBatabase Password="""";Jet OLEDB:Engine Type=18;Jet" _
, _
" OLEDBatabase Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database P" _
, _
"assword="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDBon't Copy Locale on Compact=False;" _
, "Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False"), _
Destination:=Range("A1"))
.CommandType = xlCmdTable
.CommandText = Array("A_1099")
.Name = "A_1099"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
'.SourceDataFile = "C:\db4\PORT\426950\2002\A_1099.DBF"
.Refresh BackgroundQuery:=False
End With