Printing a document via access

  • Thread starter blanic via AccessMonster.com
  • Start date
B

blanic via AccessMonster.com

Ok heres another quandry for ya, looked all day and havent found an answer.

I have been moving a bunch of batch files into access, basically the batch is
just unreliable. So in doing so here is one command I cant figure out

In dos there is a batch that prints out a file called 2230d.5 which in dos
looks like this
print /d:\\cms-apps\genicom4 2230d.5

I can send it from access as a shell command easy enough, but I really dont
like to shell, so is there a way to in VBA to print this? By the way that
printer genicom4 is on the network.
 
B

BeWyched

Hi - my again!

You can set the application's printer using:

Set Application.Printer = Application.Printers("d:\\cms-apps\genicom4")

What is the structure of the file '2230d.5'? Can it be imported into Word.
If so then the next step to print is straight forward. If it is text then the
content could be stripped out then printed - I'm not an expert here but let
me know and I'll have a think.

Cheers.

BW
 
B

blanic via AccessMonster.com

BeWyched said:
Hi - my again!

You can set the application's printer using:

Set Application.Printer = Application.Printers("d:\\cms-apps\genicom4")

What is the structure of the file '2230d.5'? Can it be imported into Word.
If so then the next step to print is straight forward. If it is text then the
content could be stripped out then printed - I'm not an expert here but let
me know and I'll have a think.

Cheers.
Unfortunately it cannot go into word, this is old stuff that im trying to
update. It uses dos to print straight to the printer, never opening in word
or anything like that. It is an ascii file, which is like a text file,
instead of 2230d.txt its called 2230d.5 which is the day it was created.
BW
Ok heres another quandry for ya, looked all day and havent found an answer.
[quoted text clipped - 8 lines]
like to shell, so is there a way to in VBA to print this? By the way that
printer genicom4 is on the network.
 
B

BeWyched

Word can handle just about any sort of text file so I would be surprised if
it cannot be used to manipulate your ASCII files. Try opening one in Word
(you will need to change the file type to 'All files' in the open dialog box
to see it).

If it works (and it should!) then the following will work - the coding opens
Word in the background, sets the printer to your choice, prints the file then
closes - you won't see Word on screen:

Private Sub PrintOldDOSStuff(OldFileName as String, UseNetworkPrinter as
String)
Dim wdApp
Set wdApp = CreateObject(Word.Application)
With wdApp
.ActivePrinter = UseNetworkPrinter
.Documents.Open OldFileName
.PrintOut
.Quit
End With

If you want users to see the file then add:
..Visible = True
before the .Quit line.
If you do this then delete the .PrintOut and .Quit lines as users will have
to trigger the print and quit Word manually.

Pass the file path and name to the routine with the printer to use - e.g.

PrintOldDOSStuff("c:\data\oldDOSfiles\2230d.5", "d:\\cms-apps\genicom4")

Good luck.

BW



blanic via AccessMonster.com said:
BeWyched said:
Hi - my again!

You can set the application's printer using:

Set Application.Printer = Application.Printers("d:\\cms-apps\genicom4")

What is the structure of the file '2230d.5'? Can it be imported into Word.
If so then the next step to print is straight forward. If it is text then the
content could be stripped out then printed - I'm not an expert here but let
me know and I'll have a think.

Cheers.
Unfortunately it cannot go into word, this is old stuff that im trying to
update. It uses dos to print straight to the printer, never opening in word
or anything like that. It is an ascii file, which is like a text file,
instead of 2230d.txt its called 2230d.5 which is the day it was created.
BW
Ok heres another quandry for ya, looked all day and havent found an answer.
[quoted text clipped - 8 lines]
like to shell, so is there a way to in VBA to print this? By the way that
printer genicom4 is on the network.
 

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