How to create a new text or data file

G

Gary Hillerson

I'm working on a template that needs to be compatible with Word '97
and later.

I use Dialogs(wdFileOpen) to ask the user to select a data file to
open (the code uses that data file). That works fine, tho I can't see
how to put a message in the dialog box or tell it to only open .dat or
..txt files.

I don't see how to use a built-in dialog (like wdFileNew) to ask for a
new text or dat file -- it wants to create a new template or document
file.

Is there a way (short of asking the user to type the full filename
into an InputBox) to do this? I'd like to allow navigation to a
directory, and then entry of the specific file name.

Thanks in advance,
gary
 
J

Jonathan West

Gary Hillerson said:
I'm working on a template that needs to be compatible with Word '97
and later.

I use Dialogs(wdFileOpen) to ask the user to select a data file to
open (the code uses that data file). That works fine, tho I can't see
how to put a message in the dialog box or tell it to only open .dat or
.txt files.

This will do the trick

With Dialogs(wdDialogFileOpen)
.Name = "*.txt;*.dat"
.Display
MsgBox .Name
End With

I don't see how to use a built-in dialog (like wdFileNew) to ask for a
new text or dat file -- it wants to create a new template or document
file.

Is there a way (short of asking the user to type the full filename
into an InputBox) to do this? I'd like to allow navigation to a
directory, and then entry of the specific file name.

You need the Save As dialog for this. Somthing like this will do nicely

With Dialogs(wdDialogFileSaveAs)
.Display
MsgBox WordBasic.FileNameInfo$(.Name, 1)
End With


--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com
 

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