Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Open dialog in macro

I have this macro that is importing a text file and manipulating the data afterwards. However, the file name is not the same every time that they run the macro. The following code is what I have, however, I would like to have an Open dialog box come up so they can choose the file and then it will import the file and do everything else. Any suggestions would be great. Thanks in advance. Matt. The first line is where I would like to have an Open dialog box because it won't always be the same name

Workbooks.OpenText Filename:="D:\JAN2004_MOMHP0000_135608.TXT", Origin:=xlWindows,
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote,
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=True, Comma:=False,
Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(
3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 4), Array(9, 4), Array(10
, 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14, 1), Array(15, 1))
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default Open dialog in macro

Matt

Use the GetOpenFileName method of the Application object.

Sub OpenTxt()

Dim FName As String

FName = Application.GetOpenFilename(",*.txt")

If Not FName Then
Workbooks.OpenText Filename:=FName, etc...
End If


End Sub

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.



"Matt" wrote in message
...
I have this macro that is importing a text file and manipulating the data

afterwards. However, the file name is not the same every time that they run
the macro. The following code is what I have, however, I would like to have
an Open dialog box come up so they can choose the file and then it will
import the file and do everything else. Any suggestions would be great.
Thanks in advance. Matt. The first line is where I would like to have an
Open dialog box because it won't always be the same name.

Workbooks.OpenText Filename:="D:\JAN2004_MOMHP0000_135608.TXT",

Origin:=xlWindows, _
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote,

_
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=True,

Comma:=False, _
Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2,

1), Array( _
3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1),

Array(8, 4), Array(9, 4), Array(10 _
, 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14, 1),

Array(15, 1))


Reply
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
Open XML dialog box Keithmeister Excel Discussion (Misc queries) 0 March 13th 09 12:20 AM
Open Dialog Box Steven Excel Discussion (Misc queries) 1 January 6th 09 10:10 PM
Open Dialog Box MichaelR Excel Worksheet Functions 1 June 5th 08 05:36 AM
open dialog box Carrie Excel Discussion (Misc queries) 1 January 19th 07 10:43 PM
Does an open dialog box slow down or stop a Macro? Doug[_9_] Excel Programming 2 January 6th 04 12:12 AM


All times are GMT +1. The time now is 12:38 AM.

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

About Us

"It's about Microsoft Excel"