Article View: comp.databases.ms-access
Article #443printing excel file within a access database
From: marcel sporck
Date: Tue, 14 Oct 1997 00:00
Date: Tue, 14 Oct 1997 00:00
42 lines
2513 bytes
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
Technical Details
Message-ID:
<620l2l$dik$1@news3.Belgium.EU.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 101bdd,dacc837efa2b8ad6,start X-Google-Attributes: gid101bdd,public X-Google-Thread: 111a5a,dacc837efa2b8ad6,start X-Google-Attributes: gid111a5a,public X-Google-Thread: 1034e6,dacc837efa2b8ad6,start X-Google-Attributes: gid1034e6,public X-Google-Thread: 10bb27,dacc837efa2b8ad6,start X-Google-Attributes: gid10bb27,public X-Google-Thread: ff0ac,dacc837efa2b8ad6,start X-Google-Attributes: gidff0ac,public X-Google-Thread: fe218,dacc837efa2b8ad6,start X-Google-Attributes: gidfe218,public X-Google-Thread: 1142f6,dacc837efa2b8ad6,start X-Google-Attributes: gid1142f6,public X-Google-Thread: 102b1d,dacc837efa2b8ad6,start X-Google-Attributes: gid102b1d,public From: "marcel sporck" <marcel.sporck@ping.be> Subject: printing excel file within a access database Date: 1997/10/14 Message-ID: <620l2l$dik$1@news3.Belgium.EU.net> X-Deja-AN: 280565243 X-MimeOle: Produced By Microsoft MimeOLE Engine V4.71.1008.3 Organization: EUnet Belgium, Leuven, Belgium Newsgroups: comp.databases.ms-access,de.comp.datenbanken.ms-access,es.comp.bd.ms-access,microsoft.public.access.devtoolkits,microsoft.public.access.forms,microsoft.public.access.formscoding,microsoft.public.access.macros,microsoft.public.access.queries,micros