hola te dejo este documento pueda que te sirva. ahora, yo te recomendaria crear el formato de encabezado antes o sea apartir de un documento, tener el formato ya diseñado a eso me refiero. al menos que las imagenes no sean las mimas, seria levantar el archivo o crear una copia del origianl y trabajarlo por si estas en red y no afectas el uso compartido de archivos.
AUTOMATIZACION DE WORD________________________________________
Local loWord
loWord = CREATEOBJECT("Word.Application")
loWord.Documents.Add()
loWord.ActiveDocument.Selection.Type("I love FoxPro!")
loWord.PrintOut()
loWord.Quit()
I cut and pasted this and got the following error:
OLE error code 0x80020011: Does not support a collection.
on the 'type' line. Is this code specific to O2K?
It's better not to work with Word's Selection object, but if you do, you need to remember that it's a member of the Word Application object, not of Document. There's only one Selection object for the entire Word instance. A better way to do this is:
Local loWord
loWord = CREATEOBJECT("Word.Application")
loWord.Documents.Add()
loRange = loWord.ActiveDocument.Range()
loRange.InsertAfter("I love FoxPro!")
loWord.ActiveDocument.SaveAs("c: emp est.doc")
loWord.PrintOut()
loWord.Quit()
release loRange, loWord
Also, be aware that if you close Word too soon after printing, it can raise an error.
Use the Background Printing Status property to see if Word is ready to be closed. -- Garrett Fitzgerald
________________________________________
To generate and send email from MS Outlook:
More generally, see Outlook Automation.
( Note: This doesn't work with OutlookExpress or other email programs, such as Eudora. Check out Tapi Fax Automation for a way to control whatever TAPI-compliant email program is registered. Eudora Is TAPI-Compliant... I don't know about OE -- wgcs)
#DEFINE MAILITEM 0
#DEFINE IMPORTANCELOW 0
#DEFINE IMPORTANCENORMAL 1
#DEFINE IMPORTANCEHIGH 2
oOutLookObject = CreateObject("Outlook.Application")
oEmailItem = oOutLookObject.CreateItem(MAILITEM)
WITH oEmailItem
.Recipients.Add("
[email protected]") && uses the Recipients collection
.Subject = "Automation sample"
.Importance = IMPORTANCENORMAL
.Body = "This is easy!"
.Attachments.Add("c:mydirsample.txt") && Note that the fully qualified path and file is required.
.Send
ENDWITH
RELEASE oEmailItem
RELEASE oOutLookObject
Note that attachments is a collection inside the message object.
For more details, check the excellent series of articles by John Petersen in FoxTalk August and September 1998
-- Alex Feldstein
Check the article http://www.vbsquare.com/internet/outlook1/
________________________________________
Also check out OLE section of Knowledge Base Watch for other samples.
http://msdn.microsoft.com/library/officedev/off2000/woobjApplication.htm
________________________________________
How can I spell check a Memo field using Word and save corrections?
In this example, mytable.memofield is the field.....
oWord=CREATEOBJECT("Word.Application")
oWord.WindowState=2
_CLIPTEXT=mytable.memofield
oWord.Documents.Add.Content.Paste
oWord.ActiveDocument.CheckSpelling()
oWord.Visible=.F.
=oWord.ActiveDocument.Select
cText=oWord.Selection.Text
cText=LEFT(cText,LEN(cText)-1)
REPLACE mytable.memofield WITH cText
_CLIPTEXT=""
oWord.Documents.Close(0)
oWord.Quit(0)
--- John Koziol
________________________________________
How can I parse an address using Outlook?
See Parsing Addresses
________________________________________
Word automation page breaks
I am using Word automation to generate a document using info pulled in from a table. Some of the sections are several pages long, so I'm using the following logic to control the page breaks:
SCAN
oRange.Collapse(0) && wdCollapseEnd
nVPos =
oRange.Information(6)/Thisform.nPtsPerInch
cText = < formatted text based on the current record >
nInches = Thisform.nLineHt * INT(LEN(cText)/Thisform.nCharsPerLine)+ 1
IF nVPos + nInches > Thisform.nBottomMargin && Not enough room on page
oRange.InsertBreak(7) && wdPageBreak
oRange.InsertAfter([(Section 1, cont.) ]+CR+CR)
ENDIF
oRange.InsertAfter(cText)
ENDSCAN
The various form properties nPtsPerInch, nLineHt, etc are set prior to running the routine based on the font selected, etc. In theory, nVPos is the vertical position in inches from the top of the page.
This works fine on my system here using Office XP, but when I get weird page breaks when I run it on the client’s machine (which has Office 2000). After inserting some debugging code, I determined the problem to be in using the value of oRange.Information(6) to determine the page position. On my system, this gets reset properly after I insert the page break, but on their computer it just keeps incrementing, so it ends up telling me it’s 16” from the top of an 11” page.
The documentation from which I learned about the oRange.Information() method was written for Office 2000, so it should not be and issue of Office versions.
Anyone have a suggestion on how to fix this or know an alternate workaround for handling the page breaks?
--SteinGoering
Douglas