Can I start the text import wizard automatically?

G

Guest

Hi everybody!
I have a file format which is actually CSV but has my own extension. I`ve
manually registered it in the windows registry to be opened by MS Excel. If I
open these files from Windows Explorer (not from Excel "Open file" dialog) I
need to start Text import wizard manually to properly format data from them.
Is there a way to launch Text import wizard automatically and with desired
settings in it? If yes, I`d like to have a solution for all versions of MS
Excel.
 
G

Guest

Only way I can think of it so turn on the macro recorder and open it
manually. When done, turn off the macro recorder and look at the recorded
code. It should be the OpenText method.

Now you can generalize the code to allow a variable file name.

If you want to be able to double click on your file and this macro kick in,
I doubt you can do that.
 
J

Jim Cone

Re: " I`d like to have a solution for all versions of MS Excel."
I can't thing of a response to this that would be appropriate.

However, I just pieced this together; see if gets you started...
'--
Sub DoItMyWay()
Dim vResult As Variant
On Error Resume Next
vResult = Application.Dialogs(xlDialogImportTextFile).Show
On Error GoTo 0
If vResult = False Then
Exit Sub
Else
'do it
End If
End Sub
'--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"pahan" <[email protected]>
wrote in message
Hi everybody!
I have a file format which is actually CSV but has my own extension. I`ve
manually registered it in the windows registry to be opened by MS Excel. If I
open these files from Windows Explorer (not from Excel "Open file" dialog) I
need to start Text import wizard manually to properly format data from them.
Is there a way to launch Text import wizard automatically and with desired
settings in it? If yes, I`d like to have a solution for all versions of MS
Excel.
 
G

Guest

Well, and what if putting such a macro in the AutoOpen macro and requiring
my customers to enable macroses in Excel? Can I alter the Excel AutoOpen
macro from my application setup program?
 
T

Tom Ogilvy

An autoopen macro is specific and is contained in the workbook being opened.
Since your files are not xls files, then there is no way to have a macro in
them.

You would need to modify each users personal.xls file (or put in an
additional equivalentfile) to instantiate application level events and
install code that would kick off the text to columns code when it recognized
that one of your text files had been opened. However, I am not sure
personal.xls is loaded when you double click on a file - you would have to
test it an see.

It seems like what you really want is to modify Excel to recognize your file
extension and process it as .CSV, but I don't believe there is a way to do
that. .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top