Printing a doc/jpg file from Access

Fekla

Registered User.
Local time
Yesterday, 22:10
Joined
Jan 7, 2007
Messages
22
Hi guys,

Can you please help me with something?
I am trying to think of some code which would permit me to send to printer a word file (which can be rtf or anything) and a jpg file. Actually the jpg is stored as a field in my database. But I dont know how to send it to printer without the whole record going into printing.
Any suggestions? Thank you in advance.
 
You might be able to print a Word document like this (I really have no experience in doing this, however):

Dim app As Word.Application
On Error Resume Next
Set app = GetObject(, "Word.Application")
If app Is Nothing Then Set app = CreateObject("Word.Application")
On Error GoTo 0
Dim doc As Word.Document
Set doc = app.Documents.Open(FileName:="C:\MyFile.Doc", Visible:=False)
doc.Activate
doc.PrintOut
doc.Close Word.WdSaveOptions.wdDoNotSaveChanges
app.Quit
Set doc = Nothing
Set app = Nothing

As for your other question, printing a JPEG, that sounds a bit more tricky. I havent' worked with images in Access. I'm guessing you could load the image into an image control (on a Report) and then use Access commands to print the report. Have you already tried that?


 
Also, if you save the image to disk, and if the user has Microsoft Office installed, then you could probably add a reference to Micorosoft office Document Imaging:

Dim miDoc As MODI.Document
Set miDoc = New MODI.Document
miDoc.Create "c:\MyImage.tif"
miDoc.PrintOut 2, 2, 1, "MyPrinter"
Set miDoc = Nothing
 
Thats how I dealed with the .doc:
Private Sub PrintStartTime()
'printing StartTime.doc
Dim intCopies, i As Integer
intCopies = InputBox("How many copies of StartTime.doc you need?", "Preparing to print...", 2)
Dim objWord As Object
Set objWord = GetObject(Application.CurrentProject.Path & "/files/StartTime.doc", "word.document")

objWord.Application.Visible = False
objWord.Activate
'somehow copies doesnt work here so loop is used
For i = 1 To intCopies
objWord.PrintOut
Next i

'Closing the doc if Word open for other applications
'or the application if only StartTime.doc is open
If objWord.Application.Documents.Count > 1 Then
objWord.Application.Visible = True
objWord.Close False ' closes the print document
Else
objWord.Application.Quit False ' closes Word
End If
Set objWord = Nothing
End Sub

as for the jpgs, they are stored as fields so i created a report with them. i m not posting its code coz its specific
 
Fekla said:
as for the jpgs, they are stored as fields so i created a report with them.
Good for you. Sounds like you got it working.
 

Users who are viewing this thread

Back
Top Bottom