PDA

View Full Version : Auto Import Text file GetOpenFilename no dialog



ljprevo
07-14-2010, 04:21 PM
Ok, long time reader first time poster!

I am fairly new to VB coding so here it goes.

I have a VB that imports VBA code into an excel workbook which then imports a text file into the excel, formats the text correctly, etc. It saves the file then closes.

We are trying to automate this whole process.

The client HAS to have the dang report in excel!! Not csv, excel.

- Mainframe creates a text file

- VB script kicks off, imports VBA code into excel macro

- text file gets imported to excel worksheet

- file is saved in excel format for customer to get.

Here is my dilemma.

We are using the GetOpenFilename command in the VBA code.

The problem with this is a dialog box opens and someone has to actually click the file to open.

Is there a way to get the text file automatically by specifying the file and not have the dialog box open?

I hope this makes sense.

I can't have the excel jut open a csv file and save as excel because of a few problems.

1. acct numbers beginning with 0. The cell has to be formatted as a text field first.

2. Long account numbers get changed to scientific format! :(

Any help would be VERY appreciated

Bob Phillips
07-15-2010, 12:27 AM
If you know the file path, why not just use open the text file.