Forms 4.5 using OLE2 ->Word97, Outlook97/98, MS Exchange
Date: Tue, 30 Mar 1999 16:34:01 GMT
Message-ID: <7dqudo$nl3$1_at_nnrp1.dejanews.com>
Please help ....getting desparate now.. (return to ca.clarke_at_elsevier.co.uk)
1).
I have a form that generates via text.io a file with html flags. I want to
open this in Word97 and print it, as word will automatically interpretes the
html formatting. (Can use ole2 to open word document .doc and print BUT if the
extension is .html the document doesn't print (see code below)
2).
As above but this time need to mail the document via Outlook97/98 -> Exchange
3).
As above but need FAX the document either via RightFax or MS Exchange.
I need to offer this functionality via ole not ora_ffi or dde, any help greatly appreciated.
Alternatively can anyone convert this VB to something OLE !!?
: Option Explicit Private Sub Command1_Click() Dim objSession As Object Dim objMessage As Object Dim objRecipient As Object 'Create the Session Object Set objSession = CreateObject("mapi.session")
'Logon using the session object
'Specify a valid profile name if you want to
'Avoid the logon dialog box
objSession.Logon profileName:="MS Exchange Settings"
'Add a new message object to the OutBox
Set objMessage = objSession.Outbox.Messages.Add
'Set the properties of the message object
objMessage.subject = "This is a test." objMessage.Text = "This is the message text."
'Add a recipient object to the objMessage.Recipients collection
Set objRecipient = objMessage.Recipients.Add
'Set the properties of the recipient object
objRecipient.Name = "John Doe" '<---Replace this with a valid 'display name or e-mail alias objRecipient.Type = mapiTo objRecipient.Resolve
'Send the message objMessage.Send showDialog:=False
MsgBox "Message sent successfully!"
'Logoff using the session object objSession.Logoff End Sub
-----------------------------------
Oracle Program Unit
PROCEDURE comms_concepts IS
BEGIN
/*
This is development code ONLY, I know it's poor but
it is only here to prove a concept..... cam 26.03.99
*/
DECLARE
ole_application ole2.obj_type; ole_document ole2.obj_type; ole_args ole2.list_type; l_in_file TEXT_IO.FILE_TYPE; l_linebuf VARCHAR2(255); l_method VARCHAR2(20):='OLE'; --hard coded to testeach method either OLE or ORA_FFI
errcode NUMBER := ERROR_CODE; dbmserrcode NUMBER; dbmserrtext VARCHAR2(255);
BEGIN if l_method='OLE' then --use OLE AUTOMATION nb. not compatible with WORD95, only works with Word97 due to diff object model/word.basic
if :cg$ctrl.cmm_code = 'SGML' then --(name gets shortened to 3digit extension)
/* **** PRINTING ***** */ /* * This is hardcoded stuff at the moment for testing purposes only */ -- Create the Word.Application and make it visible ole_application:= ole2.create_obj('Word.Application'); ole2.set_property(ole_application,'Visible',1); -- Get a handle on the documents collection ole_document := ole2.get_obj_property(ole_application, 'Documents'); -- What word file to open ole_args:= ole2.create_arglist; --message('file '|| 'q:
\in.sgm\agee\'||:global.eas$mnt_id||:global.eas$mtn_seq_no||'.'||substr (:cg$ctrl.cmm_code,1,3));
/* This won't work need to use .htm extension therefore requires changes to database tables such as update EAS_COMMUNICATION_TEMPLATES replace SGML with HTML, need also to migrate SGML to HTML flag settings problem being SGML is hardcoded is eas$iface package and library routines MAYBE quicker / dirty but just rename the file from .sgm to .htm so that word interpretes it correctly
ole2.add_arg(ole_args, 'q:
\in.sgm\agee\'||:global.eas$mnt_id||:global.eas$mtn_seq_no||'.'||substr
(:cg$ctrl.cmm_code,1,3));
*/
--ole2.add_arg(ole_args, 'q:
\in.sgm\agee\'||:global.eas$mnt_id||:global.eas$mtn_seq_no||'.'||'htm');
ole2.add_arg(ole_args, 'e:\temp\test1.doc'); -- Open Word document specified in the argument list ole_document := ole2.invoke_obj(ole_document, 'Open', ole_args); ole2.destroy_arglist(ole_args);
--Print the Word document, nb. all arguements optional
ole_args:= ole2.create_arglist; ole2.add_arg(ole_args, 'True'); --Background ole2.add_arg(ole_args, 'False'); --Append ole2.add_arg(ole_args,'wdPrintAllDocument'); --Range --
wdPrintAllDocument,wdPrintCurrentPage,wdPrintFromTo,wdPrintRangeOfPages,wdPri
ntS election ole2.add_arg(ole_args, 'False'); --OutputFileName ole2.add_arg(ole_args, 'null'); --From ole2.add_arg(ole_args, 'null'); --To ole2.add_arg(ole_args, 'wdPrintDocumentContent'); --Item -- wdPrintAutoTextEntries,wdPrintComments,wdPrintDocumentContent,wdPrintKeyAssig nme nts,wdPrintProperties,wdPrintStyles. ole2.add_arg(ole_args, '1'); --Copies ole2.add_arg(ole_args, 'null'); --Pages ole2.add_arg(ole_args, 'wdPrintAllPages'); --PageType -- wdPrintAllPages,wdPrintEvenPagesOnly,wdPrintOddPagesOnly ole2.add_arg(ole_args, 'False'); --PrintToFile ole2.add_arg(ole_args, 'True'); --Collate ole2.add_arg(ole_args, 'null'); --FileName ole2.add_arg(ole_args, 'null'); -- ActivePrinterMacGX ole2.add_arg(ole_args, 'null'); -- ManualDuplexPrint --ole2.invoke(ole_application, 'PrintOut'); ole2.invoke(ole_application, 'PrintOut', ole_args); ole2.destroy_arglist(ole_args);
elsif :cg$ctrl.cmm_code = 'MGW' then
/* **** MAILING **** */ -- Create the Word.Application and make it visible ole_application:= ole2.create_obj('Word.Application'); ole2.set_property(ole_application,'Visible',1); -- Get a handle on the documents collection ole_document := ole2.get_obj_property(ole_application, 'Documents'); -- What word file to open ole_args:= ole2.create_arglist;
/* * This is hardcoded stuff at the moment for testing purposes only */
message('file '|| 'q:
\in.mgw\agee\'||:global.eas$mnt_id||:global.eas$mtn_seq_no||'.'||:cg$ctrl.cmm
_co de); ole2.add_arg(ole_args, 'q:
\in.mgw\agee\'||:global.eas$mnt_id||:global.eas$mtn_seq_no||'.'||:cg$ctrl.cmm
_co de); -- Open Word document specified in the argument list ole_document
:= ole2.invoke_obj(ole_document, 'Open', ole_args);
ole2.destroy_arglist(ole_args);
--Mail the Word document
ole_args:= ole2.create_arglist; --ole2.add_arg(ole_args, '?'); --Item ole2.invoke(ole_application, 'SendMail'); --ole2.invoke(ole_application, 'SendMail', ole_args); ole2.destroy_arglist(ole_args);
elsif :cg$ctrl.cmm_code = 'FAX' then
/* **** FAX ***** */ message('file '|| 'q:
\in.mgw\agee\'||:global.eas$mnt_id||:global.eas$mtn_seq_no||'.'||:cg$ctrl.cmm
_co de); ole2.add_arg(ole_args, 'q:
\in.fax\agee\'||:global.eas$mnt_id||:global.eas$mtn_seq_no||'.'||:cg$ctrl.cmm
_co de); -- Open Word document specified in the argument list ole_document
:= ole2.invoke_obj(ole_document, 'Open', ole_args);
ole2.destroy_arglist(ole_args);
--Fax the Word document
ole_args:= ole2.create_arglist; ole2.add_arg(ole_args, '01865843967'); --fax number ole2.add_arg(ole_args, 'EASE TEST FAX'||to_char(sysdate,'DD-MON- YYYY HH24:MI')); --subject line <=255 characters --ole2.invoke(ole_application, 'SendFax'); ole2.invoke(ole_application, 'SendFax', ole_args); ole2.destroy_arglist(ole_args);
else
/* **** SOMETHING ELSE !!! should never happen ***** */
message('ERROR - :cg$ctrl.cmm_code ='||:cg$ctrl.cmm_code); end if;
--Release the OLE objects
ole2.release_obj(ole_application);
ole2.release_obj(ole_document);
else --must be using mapi.dll and intermediate datatype .dll
null;
end if;
EXCEPTION
when others then
dbmserrcode :=DBMS_ERROR_CODE;
dbmserrtext :=DBMS_ERROR_TEXT;
message(to_char(dbmserrcode)||' - '||dbmserrtext);
END;
END;
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
Received on Tue Mar 30 1999 - 18:34:01 CEST