Avatar of aikimark
Flag for United States of America asked on

xlDialogOpenText dialog use

I can't seem to get my VBA code to open the Text Import wizard in an Excel2003 environment.

It doesn't like any of the following:
Application.Dialogs(xlDialogOpenText).Show (parmSelectedFolder & "\ImportFmt3.Txt")

Open in new window

I've found old (Excel97) MS documentation stating that not all the enumerations work, but surely they've fixed that by now.
Microsoft Excel

Avatar of undefined
Last Comment

8/22/2022 - Mon
Gerwin Jansen

Well, Application.Dialogs(xlDialogOpen).Show is opening the file open dialog but if you want to import a text file with xlDialogOpenText you have to specify a lot more parameters like these:
file_name, file_origin, start_row, file_type, text_qualifier, consecutive_delim, tab, semicolon, comma, space, other, other_char, field_info

I need the user to supply some of the information to the opentext dialog wizard.  The problem I face is that sometimes, the user wants to override the (default) text import actions of the application.
Gerwin Jansen

Well, I think the issue is that you can't just launch the wizard though VBA, if you record a macro doing that, the result will be a "Workbooks.OpenText ..." piece of code.

You could present the user with a file selection dialogue like this:

filePath = Application.GetOpenFilename("CSV (Comma Delimited) (*.csv),*.csv", 1, "Select a file", , False)

Then followed by a Workbooks.OpenText ... with some default values set.

I'll try to to find you a method on launching the wizard but I doubt it is possible.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Rory Archibald



Yes.  I stated that I'd read the Excel97 KB article in my question.
Rory Archibald

I overlooked that! I don't think they intend to fix those, but can you not just use:
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.


Unfortunately, there are no arguments for the xlDialogImportTextFile dialog.

In this case, I know the path and name of the file to be imported.  I want to present the user with the text import wizard without first requiring them to select the file.
Rory Archibald

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

That seems to be the only work-around other that reinventing the import wizard or using a third-party component.