🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.databases.ms-access
1 messages
1 total messages Started by marcel sporck Tue, 14 Oct 1997 00:00
printing excel file within a access database
#443
Author: marcel sporck
Date: Tue, 14 Oct 1997 00:00
42 lines
2513 bytes
My problem : sometimes i need to print a excel report from within access.
I'am using some code to make a connection to the excel file, but whenever i
print, i can't close excel from within access.  When i don't print there is
no problem to do so.
Who can help me ?
PS : i'am using access 2.0 and win 3.11
Here is the code :
Sub PRINT_EXCEL_FILE()
    Dim varChannelNumber As Variant
    Dim intTaskID As Integer
    Dim varValue As Variant
    Dim intRet As Integer

    ' Start Excel
    intTaskID = Shell("c:\Msoffice\Excel\excel.exe", 2)

    ' Open a channel
    varChannelNumber = DDEInitiate("excel" & glrUIntFromInt(intTaskID),
"System")

    ' Open the spreadsheet
    DDEExecute varChannelNumber, "[Open(""e:\tepcc\bckup\posy.xls"")]"

    ' Close the channel
    DDETerminate varChannelNumber

    ' Open a channel to the spreadsheet
    varChannelNumber = DDEInitiate("excel" & glrUIntFromInt(intTaskID),
"posy.xls")

    ' print report
    DDEExecute varChannelNumber, "[Print(1,0)]"
    ' Clean up
    DDETerminate varChannelNumber
    intRet = DoEvents()

    ' Close Excel
    intRet = glrCloseApp(intTaskID)
End Sub
Thanks for your help,
marcel.sporck@ping.be
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads