Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print Automatically from Notepad 1

Status
Not open for further replies.

johanap

Technical User
Oct 16, 2002
9
0
0
BE
I have a button in a form to export a (temporary) table to a text file. This works fine with the code :

DoCmd.TransferText acExportDelim, "TestExporteren.txt", "TestTable", "D:\TEST\TestExporteren" & ".txt", True

Is there a code to Print also automatically the Text file (TestExporteren.txt) that was created in Notepad ?

Thank you very much.
 
The command line for opening a file in notepad is:
Code:
notepad.exe /p <filename>

To execute the command from access, you will need to use the Shell function. The complete code will look something like this:

Code:
'Declare the variables
Dim ExportFileName
Dim NotepadPrint

' Set the value of ExportFileName to the desired file name.
' This is done so that in the future you can use user
' entered values to change the file name.
ExportFileName = &quot;D:\TEST\TestExporteren.txt&quot;

' Create the export file using the transfertext command.
DoCmd.TransferText acExportDelim, &quot;TestExporteren.txt&quot;, &quot;TestTable&quot;, ExportFileName, True

' Open Notepad to print the file.  It is important to
' note that notepad will close once the file has printed.
NotepadPrint = Shell(&quot;notepad.exe /p &quot; & ExportFileName)

I hope this is helpfull.
 
It works !

Thank you very much JediBMC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top