LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Help Importing using GetOpenFilename

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing Alan Beban's code on Arrays; Importing a module or a project Steve G Excel Worksheet Functions 4 August 27th 07 04:18 PM
GetOpenFileName with F*.txt DRK Excel Programming 6 June 7th 05 12:45 PM
GetOpenFilename Jenny Excel Programming 2 October 22nd 04 01:38 PM
GetOpenFileName Greg Bloom Excel Programming 2 February 9th 04 04:09 PM
GetOpenFilename Greg Bloom Excel Programming 0 February 9th 04 03:32 PM


All times are GMT +1. The time now is 11:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"