Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add Open File Prompt to Excel Macro 1

Status
Not open for further replies.

prismtx

IS-IT--Management
Apr 9, 2001
59
US
I have not done any macro coding before, but I am trying to set up a macro to open a pipe delimited that is generated on a daily basis. I set up a macro to open it without having to go thru the import wizard every time, but it only opens the original file name. The file has the date as part of the name, so the name is different every day.

Can I modify my macro to prompt for the file to open, and then continue once it is selected?

Here is the start of what the macro recording in Excel gave me:

Sub PipeLoad()
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Download\DailyReport20080125.csv", Destination:=Range("A1"))
.Name = "DailyReport20080125"
.FieldNames = True
etc.
 




Hi,

Check out the GetOpenFilename Method

Skip,

[glasses]Did you hear what happened when the OO programmer lost his library?...
He's now living in OBJECT poverty![tongue]
 
Thanks Skip.

I got it to work! Here's the code:

Filename = Application.GetOpenFilename("CSV Files (*.csv), *.csv")

With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & Filename, Destination:=Range("A1"))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top