print excel ole object

G

Guest

I'm using/openning excel ole object directly from db (it's saved in a db
table's field).
I'm using the following code:
Set db = CurrentDb
Set rst = db.OpenRecordset(strSQL)

With Me.oleBoundObj

Set oSheet = .Object.Sheets(2)
oSheet.Cells(2, 2).Value = rst![dAvAN]
oSheet.Cells(3, 2).Value = rst![dAvBN]
......
Set oSheet = Nothing

.OLETypeAllowed = acOLEEmbedded

End With
Everything is working fine. But, when I'm trying to print it the whole app
is freezing.
I tried this code for printing:
'Dim oSheet As Object
With Me.oleBoundObj
.OLETypeAllowed = acOLEEmbedded
Set oSheet = .Object.Sheets(1)
oSheet.PrintPreview

Set oSheet = Nothing
End With

Could anybody advise anything?

Thanks,

Alex
 
G

Guest

I found a very simple solution and it's working very well.

Private Sub cmdPrint_Click()
Dim oSheet As Object
With Me.oleBoundObj

Set oSheet = .Object.Sheets(1)

oSheet.PrintOut Copies:=1, _
Collate:=True
Set oSheet = Nothing
End With

End Sub
 

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