Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello. I am new to VBA, and I've been having trouble setting up a macro to
import a file using GetOpenFilename. What I did is I recorded a macro when I imported the file so that all the code related to editing the imported data was recorded, then I entered the GetOpenFilename function above that, and substituted the file path for the strFileName variable. I know the file path gets saved under strFileName, but it won't open/import the file, and I don't know what to do!:( My code is below. I would really appreciate your help. Thanks! Dim strFileName As String Dim strMessage As String strFileName = Application.GetOpenFilename("LAS Files (*.las), *.las)", , "Select Import File") strMessage = "You selected the '" & strFileName & "' file." MsgBox strMessage Sheets("Read Me First").Select Range("L1").Select ActiveSheet.Unprotect With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;& strFileName", Destination:=Range( _ "L1")) .Name = "Data_16" .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 = True .TextFileTabDelimiter = True .TextFileSemicolonDelimiter = False .TextFileCommaDelimiter = False .TextFileSpaceDelimiter = True .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1) .TextFileTrailingMinusNumbers = True '.Refresh BackgroundQuery:=False End With |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Importing Alan Beban's code on Arrays; Importing a module or a project | Excel Worksheet Functions | |||
GetOpenFileName with F*.txt | Excel Programming | |||
GetOpenFilename | Excel Programming | |||
GetOpenFileName | Excel Programming | |||
GetOpenFilename | Excel Programming |