Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Below is a macro that I now have working. The text file I'm trying to select
will always be in the same directory as the XLS itself. What I'm hoping to do is rather than have a hard coded in as "H:\XLS", I'd like to symbolic this directory to the same as the XLS. Is there a variable I can use that knows what directory the XLS is running out of and is there a way to use it below? thanks in advance for your help ================= Sub ImportProgramData() Dim file_name As Variant Range("A3:G300").Select Selection.ClearContents Application.DefaultFilePath = "H:\XLS" 'Set default file path to root file_name = Application.GetOpenFilename With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;" & file_name _ , Destination:=Range("A3:G300")) ..Name = "ImportProgramData" ..FieldNames = True ..RowNumbers = False ..FillAdjacentFormulas = False ..PreserveFormatting = True ..RefreshOnFileOpen = False ..RefreshStyle = xlInsertDeleteCells ..SavePassword = False ..SaveData = True ..AdjustColumnWidth = True ..RefreshPeriod = 0 ..TextFilePromptOnRefresh = False ..TextFilePlatform = 437 ..TextFileStartRow = 1 ..TextFileParseType = xlDelimited ..TextFileTextQualifier = xlTextQualifierDoubleQuote ..TextFileConsecutiveDelimiter = False ..TextFileTabDelimiter = True ..TextFileSemicolonDelimiter = False ..TextFileCommaDelimiter = False ..TextFileSpaceDelimiter = False ..TextFileOtherDelimiter = "|" ..TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1) ..TextFileTrailingMinusNumbers = True ..Refresh BackgroundQuery:=False End With ActiveWorkbook.Save End Sub ============================= |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Save to a location other than default | Excel Discussion (Misc queries) | |||
Macro - save to current location vs excel default location | Excel Discussion (Misc queries) | |||
Default comment location | Excel Worksheet Functions | |||
default file location | Excel Discussion (Misc queries) | |||
Default File Location | Excel Programming |