Question : import macro in excel

I am tring to write a macro that will import text files into an excel spreadsheet the name of the text vary and are listed in cell b1 of each sheet.  What I have right now is

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 5/8/2003 by ML
'
' Keyboard Shortcut: Ctrl+Shift+I
'
    With ActiveSheet.QueryTables.Add(Connection:= _
        "TEXT;C:\WINNT\Desktop\28136438.", Destination:=Range("A2"))
        .Name = "28136438."
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .TextFilePromptOnRefresh = False
        .TextFilePlatform = xlWindows
        .TextFileStartRow = 1
        .TextFileParseType = xlDelimited
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = True
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = False
        .TextFileSpaceDelimiter = False
        .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
        .Refresh BackgroundQuery:=False
    End With
End Sub

this uses the import wizard but the problem is I need "TEXT;C:\WINNT\Desktop\28136438.", this to be changed so that it imports the file that is in cell b1 and not C:\WINNT\Desktop\28136438.  I appreciate any help on this.  Thanks in advance.

Answer : import macro in excel

Actually, you don't replace the "TEXT;" part. Like this.

*********************************************************

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 5/8/2003 by ML
'
' Keyboard Shortcut: Ctrl+Shift+I
'
   With ActiveSheet.QueryTables.Add(Connection:= _
       "TEXT;" & [B1], Destination:=Range("A2"))
       .Name = "Book2."
       .FieldNames = True
       .RowNumbers = False
       .FillAdjacentFormulas = False
       .PreserveFormatting = True
       .RefreshOnFileOpen = False
       .RefreshStyle = xlInsertDeleteCells
       .SavePassword = False
       .SaveData = True
       .AdjustColumnWidth = True
       .RefreshPeriod = 0
       .TextFilePromptOnRefresh = False
       .TextFilePlatform = xlWindows
       .TextFileStartRow = 1
       .TextFileParseType = xlDelimited
       .TextFileTextQualifier = xlTextQualifierDoubleQuote
       .TextFileConsecutiveDelimiter = False
       .TextFileTabDelimiter = True
       .TextFileSemicolonDelimiter = False
       .TextFileCommaDelimiter = False
       .TextFileSpaceDelimiter = False
       .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
       .Refresh BackgroundQuery:=False
   End With
End Sub

*********************************************************

WATYF
Random Solutions  
 
programming4us programming4us