both
On Error GoTo CancelSelected 'Sets the filters for file types CMDialog1.Filter = "Text (*.txt)|*.txt|All Files (*.*)|*.*" 'Picks the filter to show when the box first opens CMDialog1.FilterIndex = 1 'Shows in the filename box and sets the pattern CMDialog1.Filename = "*.txt" 'Causes an error if the user picks cancel so that you know for a fact cancel was selected CMDialog1.CancelError = True 'Opens the box CMDialog1.Action = 1
Once the user selects a file, it can be gotten using:
FileName = CMDialog1.FileName
For a "Save" box, add the following line somewhere before the"CMDialog1.Action" line:
CMDialog1.DefaultExt = "TRT"
and set CMDialog1.Action to 2.Again, the filename is gotten by:
I don't remember the printer box code and my help files say the commondialog topics can't be found.
To save a file (there are MANY ways, this is just one):
Open FileName For Output As 1 Print #1, TextToSave Close
To open a file (again, MANY ways):
Open FileName For Input As 1 TextToGet = Input(LOF(1), 1) Close
To print a ASCII (standard text) file (MANY ways, again):
After getting the file's contents using a method such as the one above:
Printer.Print TextToGet Printer.EndDoc
For more info, search in the help files for:
CommonDialogOpenInputPrint #Printer
Hope this helps!
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
both
On Error GoTo CancelSelected
'Sets the filters for file types
CMDialog1.Filter = "Text (*.txt)|*.txt|All Files (*.*)|*.*"
'Picks the filter to show when the box first opens
CMDialog1.FilterIndex = 1
'Shows in the filename box and sets the pattern
CMDialog1.Filename = "*.txt"
'Causes an error if the user picks cancel so that you know for a fact cancel was selected
CMDialog1.CancelError = True
'Opens the box
CMDialog1.Action = 1
Once the user selects a file, it can be gotten using:
FileName = CMDialog1.FileName
For a "Save" box, add the following line somewhere before the"CMDialog1.Action" line:
CMDialog1.DefaultExt = "TRT"
and set CMDialog1.Action to 2.
Again, the filename is gotten by:
FileName = CMDialog1.FileName
I don't remember the printer box code and my help files say the commondialog topics can't be found.
To save a file (there are MANY ways, this is just one):
Open FileName For Output As 1
Print #1, TextToSave
Close
To open a file (again, MANY ways):
Open FileName For Input As 1
TextToGet = Input(LOF(1), 1)
Close
To print a ASCII (standard text) file (MANY ways, again):
After getting the file's contents using a method such as the one above:
Printer.Print TextToGet
Printer.EndDoc
For more info, search in the help files for:
CommonDialog
Open
Input
Print #
Printer
Hope this helps!