16 Mai 2013 18:00
Function Abre_word(CPASTA, CARQ)
Local oWord
Local oFILE
Local ArqDoc
oFILE := CPASTA + cARQ
cARQ := CPASTA + cARQ + ".TXT"
ArqDoc := oFILE + ".doc"
Copy File (cARQ) TO (oFILE)
RenameFile( oFILE, ArqDoc )
oWord:=TOleAuto():New( "Word.Application" )
oWord:Documents:Open( ArqDoc )
oWord:WindowState := 1
oWord:Visible := .t.
Return nil
FUNCTION Gera_WORD(CPASTA, CARQ,CARQDOC)
LOCAL lWord:=.T.
IF ( oWord := Win_oleCreateObject( "Word.Application" ) ) = Nil
ALERT( "ATENÇÃO! Word não está instalado nesta máquina. Não será possível gerar o documento.")
lWord:=.F.
ENDIF
IF lWord
oDoc := oWord:Documents:Add()
oText := oWord:Selection()
* TRY
oDoc:SaveAs( CPASTA + CARQDOC)
* CATCH
* ALERT( "ATENÇÃO! o documento "+ CARQDOC +" está aberto, feche-o antes da impressão.")
* hJanela:=HWG_FindWindow(0 ,cNomeArq+" - Microsoft Word")
* hwg_BringWindowToTop( hJanela )
* ShowWindow( hJanela, SW_MAXIMIZE )
* RETURN .F.
* END
oWord:Visible := .F.
oText:PageSetup():Orientation:=0 // 0=Portrait, 1=Landscape
oText:PageSetup():TopMargin:=30
oText:PageSetup():BottomMargin:=10
oText:PageSetup():LeftMargin:=30
oText:PageSetup():RightMargin:=3
oText:PageSetup():PageWidth:=595.35
oText:PageSetup():PageHeight:=841.95
oText:Font:Name := "Courier New"
oText:Font:Size := 11
oText:Font:Bold := .F.
FT_FUSE( CPASTA + CARQ )
DO WHILE !FT_FEOF()
cLinha :=FT_FREADLN()
lEject :=(Chr(12) $ cLinha) // Procura caracter EJECT
lEspecial:=(Chr(27)+"P" $ cLinha)
IF !lEspecial
lEspecial:=(Chr(27)+"P"+Chr(15) $ cLinha)
ENDIF
* Elimina as formatações ou códigos de impressão
cLinha:=StrTran(cLinha,Chr(12)) // Elimina caracter EJECT
cLinha:=StrTran(cLinha,Chr(13))
cLinha:=StrTran(cLinha,Chr(27)+"P"+Chr(15))
cLinha:=StrTran(cLinha,Chr(12),Chr(13)+Chr(13))
cLinha:=StrTran(cLinha,Chr(27)+"P")
IF lEspecial
FT_FSKIP()
LOOP
ENDIF
oText:TypeText(cLinha+ hb_eol())
FT_FSKIP()
IF lEject .AND. !FT_FEOF()
oText:InsertBreak(1) //Gera quebra de página no word.
ENDIF
ENDDO
FT_FUSE()
oWord:Visible := .T.
oWord:WindowState := 1
oDoc:Save()
nLinhaWord:=1
nPaginaWord:=1
oWord:Selection():GoTo(nLinhaWord,,nPaginaWord) //Posiciona na primeira linha da primeira página
ENDIF
RETURN lWord
16 Mai 2013 19:05
16 Mai 2013 19:56
-lhbct
-inc
-lxhb
-lhbwin
-llibnf
-oSIGECOM.EXE
MAIN.PRG
AUDIT.PRG
BROWTEXT.PRG
CALCULAR.PRG
CALENDAR.PRG
CLIENTES.PRG
DANFE.PRG
DANFEDIV.PRG
DOCHEQUE.PRG
DOCOMPRA.PRG
DOCONTAS.PRG
DONFISC.PRG
DOPEDIDO.PRG
DOPRODUT.PRG
...
hbmk2: Harbour: Compilando módulos...
Harbour 3.0.0 (Rev. 16951)
Copyright (c) 1999-2011, http://harbour-project.org/
Compiling 'PRINTSERV.PRG'...
Lines 258, Functions/Procedures 6
Generating C source output to '.hbmk\win\bcc\PRINTSERV.c'... Done.
hbmk2: Compilando...
.hbmk\win\bcc\PRINTSERV.c:
hbmk2: Linkando... SIGECOM.EXE
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external '_hb_retcAdopt' referenced from C:\HB30\LIB\WIN\BCC\L
IBNF.LIB|fttext
hbmk2: Erro: Executando linkeditor. 2
ilink32.exe @C:\DOCUME~1\Amparo\CONFIG~1\Temp\ejkmx6.lnk
17 Mai 2013 08:42
FUNCTION Gera_WORD( CPASTA, CARQUI )
LOCAL lWord := .T.
LOCAL ARQTXT := ""
LOCAL ARQWOR := ""
IF ( oWord := Win_oleCreateObject( "Word.Application" ) ) = Nil
ALERT( "ATENÇÃO! Word não está instalado nesta máquina. Não será possível gerar o documento.")
lWord:=.F.
ENDIF
ARQTXT := CPASTA + CARQUI + ".TXT"
ARQWOR := CPASTA + CARQUI + ".DOC"
IF lWord
oDoc := oWord:Documents:Add()
oText := oWord:Selection()
oDoc:SaveAs( ARQWOR )
oWord:Visible := .F.
oText:PageSetup():Orientation:=0 // 0=Portrait, 1=Landscape
oText:PageSetup():TopMargin:=0 //TopMargin:=30
oText:PageSetup():BottomMargin:=0 //BottomMargin:=10
oText:PageSetup():LeftMargin:=0 //LeftMargin:=30
oText:PageSetup():RightMargin:=0 //RightMargin:=3
oText:PageSetup():PageWidth:=595.35 //PageWidth:=595.35
oText:PageSetup():PageHeight:=841.95 //PageHeight:=841.95
oText:Font:Name := "Arial" //"Courier New"
oText:Font:Size := 14
oText:Font:Bold := .F.
FT_FUSE( ARQTXT )
DO WHILE !FT_FEOF()
cLinha :=FT_FREADLN()
lEject :=(Chr(12) $ cLinha) // Procura caracter EJECT
lEspecial:=(Chr(27)+"P" $ cLinha)
IF !lEspecial
lEspecial:=(Chr(27)+"P"+Chr(15) $ cLinha)
ENDIF
* Elimina as formatações ou códigos de impressão
cLinha:=StrTran(cLinha,Chr(12)) // Elimina caracter EJECT
cLinha:=StrTran(cLinha,Chr(13))
cLinha:=StrTran(cLinha,Chr(27)+"P"+Chr(15))
cLinha:=StrTran(cLinha,Chr(12),Chr(13)+Chr(13))
cLinha:=StrTran(cLinha,Chr(27)+"P")
IF lEspecial
FT_FSKIP()
LOOP
ENDIF
oText:TypeText(cLinha+ hb_eol())
FT_FSKIP()
IF lEject .AND. !FT_FEOF()
oText:InsertBreak(1) //Gera quebra de página no word.
ENDIF
ENDDO
FT_FUSE()
oWord:Visible := .T.
oWord:WindowState := 1
oDoc:Save()
nLinhaWord:=1
nPaginaWord:=1
oWord:Selection():GoTo(nLinhaWord,,nPaginaWord) //Posiciona na primeira linha da primeira página
ENDIF
RETURN lWord
17 Mai 2013 19:11
20 Mai 2013 20:22
29 Mai 2013 14:31
29 Mai 2013 15:13
29 Mai 2013 23:59
Sub Macro3()
'
' Macro3 Macro
'
'
Selection.TypeText Text:="teste de macro"
Selection.MoveLeft Unit:=wdCharacter, Count:=14, Extend:=wdExtend
Selection.Font.Size = 22
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveLeft Unit:=wdCharacter, Count:=15
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:="T"
End Sub
30 Mai 2013 00:15
Hi all , after a lot of try and fail I got what is expected.
It´s VB problem related to RANGE and SELECTION.
The code that works :
#include 'winpar.ch' -> Define for Windows variables wd...
******************************************************************************
function table_form()
******************************************************************************
* Parameter vtbl -> order data array
para vtbl
LOCAL oWord,__text
TRY
oWord := CreateObject( "Word.Application" )
CATCH
Alert( "ERROR! Word not avalable. [" + Ole2TxtError()+ "]" )
retu NIL
END
oWord:Visible := .T.
* Creating new Doc
odoc := oWord:Documents:Add()
* DOC Setup
-----------------------------------------------------------------
*odoc:PageSetup:Orientation(wdOrientLandscape)
* Don't know why but Word Function CentimetersToPoints cause LINKER
error ?!
*odoc:PageSetup:TopMargin := oWord:CentimetersToPoints(2.5)
odoc:PageSetup:TopMargin := 80 // points
odoc:PageSetup:BottomMargin := 60
odoc:PageSetup:LeftMargin := 60
odoc:PageSetup:RightMargin := 40
*odoc:PageSetup:Gutter := 0
odoc:PageSetup:HeaderDistance := 40
odoc:PageSetup:FooterDistance := 40
*odoc:PageSetup:PageWidth := 21
*odoc:PageSetup:PageHeight := 29.7
*odoc:PageSetup:VerticalAlignment := wdAlignVerticalTop
* DOC Setup
-----------------------------------------------------------------
* Header
--------------------------------------------------------------------
odoc:ActiveWindow:ActivePane:View:SeekView(wdSeekCurrentPageHeader)
odoc:Select()
oWord:Selection:ParagraphFormat:Alignment := wdAlignParagraphCenter
oWord:Selection:Font:Name := "Arial"
oWord:Selection:Font:Bold := wdToggle
__text := hb_oemtoansi("Order Confirmation")
oWord:Selection:TypeText(__text)
* Header
--------------------------------------------------------------------
* Footer
--------------------------------------------------------------------
odoc:ActiveWindow:ActivePane:View:SeekView(wdSeekCurrentPageFooter)
odoc:Select()
oWord:Selection:ParagraphFormat:Alignment := wdAlignParagraphLeft
oWord:Selection:Font:Name := "Arial"
oWord:Selection:Font:Bold := wdToggle
oWord:Selection:Font:Size := 6
* Order number
*
__text := hb_oemtoansi("PD"+ pdv->codigo + ".DOC")
oWord:Selection:TypeText(__text)
* Blank Lines
oWord:Selection:TypeParagraph()
oWord:Selection:TypeParagraph()
oWord:Selection:ParagraphFormat:Alignment := wdAlignParagraphCenter
oWord:Selection:Font:Name := "Arial"
oWord:Selection:Font:Bold := wdToggle
oWord:Selection:Font:Size := 8
__auto := 'AUTOTEXT "P gina X de Y" '
__auto := hb_oemtoansi(__auto)
oWord:Selection:Fields:Add(oWord:Selection:Range, -1, __auto, .T.)
* Footer
--------------------------------------------------------------------
* Return Active Doc
---------------------------------------------------------
odoc:ActiveWindow:ActivePane:View:SeekView(wdSeekMainDocument)
* First Paragraph , just to assign a range for table 1
opr1 := odoc:Paragraphs:Add() // paragrafo 1 para Tab1
rng1 := opr1:Range
otb1 := odoc:Tables:Add(rng1, 3, 2)
* Tab1 setup
otb1:Borders:OutsideLineStyle := wdLineStyleSingle
otb1:Borders:InsideLineStyle := wdLineStyleNone
otb1:Select()
oWord:Selection:Cells:VerticalAlignment := wdCellAlignVerticalCenter
* Tab1 rows and cols setup
otb1:Rows:Item(1):Height := 18
otb1:Rows:Item(2):Height := 12
otb1:Rows:Item(3):Height := 12
otb1:Columns:Item(1):PreferredWidth := 350
otb1:Columns:Item(2):PreferredWidth := 100
* Fill the cells
__text := 'ACME INC.' + ' - '
__text += 'Pedido : ' + alltrim(pdv->codigo)
otb1:Cell(1, 1):Range:Font:Name := "Arial"
otb1:Cell(1, 1):Range:Font:Size := 10
otb1:Cell(1, 1):Range:Font:Bold := wdToggle
otb1:Cell(1, 1) := __text
otb1:Cell(1, 1):Range:Select()
oWord:Selection:MoveRight(wdCell,1)
__text := 'Data : ' + dtoc(pdv->dtinic)
otb1:Cell(1, 2):Range:Font:Name := "Arial"
otb1:Cell(1, 2):Range:Font:Size := 10
otb1:Cell(1, 2):Range:Font:Bold := wdToggle
otb1:Cell(1, 2) := __text
otb1:Cell(1, 2):Range:Select()
oWord:Selection:MoveLeft(wdCell,1)
otb1:Cell(1, 2):Range:Select()
oWord:Selection:MoveLeft(wdCell,1)
__text := alltrim(cad->end) + ' - ' + alltrim(cad->bai)
__text += ' , ' + alltrim(cad->cid) + ' , ' + cad->uf
__text += ' - CEP : ' + alltrim(cad->cep)
otb1:Cell(2, 1):Range:Font:Name := "Arial"
otb1:Cell(2, 1):Range:Font:Size := 9
otb1:Cell(2, 1) := __text
otb1:Cell(2, 1):Range:Select()
oWord:Selection:MoveRight(wdCell,1)
__text := 'Resp. LYC : Caio'
otb1:Cell(2, 2):Range:Font:Name := "Arial"
otb1:Cell(2, 2):Range:Font:Size := 9
otb1:Cell(2, 2):Range:Font:Bold := wdToggle
otb1:Cell(2, 2) := __text
otb1:Cell(2, 2):Range:Select()
oWord:Selection:MoveLeft(wdCell,1)
__text := 'Tel. / Fax : ' + alltrim(cad->fone1) + ' / ' + alltrim(cad-
>fone2)
otb1:Cell(3, 1):Range:Font:Name := "Arial"
otb1:Cell(3, 1):Range:Font:Size := 9
otb1:Cell(3, 1) := __text
otb1:Cell(2, 1):Range:Select()
oWord:Selection:MoveRight(wdCell,1)
otb1:Cell(3, 2):Range:Select()
oWord:Selection:Collapse(wdCollapseEnd)
* Closing Tab1 range , selection
* Blank Line
opr2 := odoc:Paragraphs:Add() // paragrafo 2
rng2 := opr2:Range
rng2:Select()
oWord:Selection:Collapse(wdCollapseEnd)
* Client Data
wlixo:=cli->(at_seek(pdv->codimp,.f.))
opr3 := odoc:Paragraphs:Add() // paragrafo 3 , Tab2
rng3 := opr3:Range
otb2 := odoc:Tables:Add(rng3, 3, 2)
otb2:Borders:OutsideLineStyle := wdLineStyleSingle
otb2:Borders:InsideLineStyle := wdLineStyleNone
otb2:Select()
oWord:Selection:Cells:VerticalAlignment := wdCellAlignVerticalCenter
otb2:Rows:Item(1):Height := 18
otb2:Rows:Item(2):Height := 12
otb2:Rows:Item(3):Height := 12
otb2:Columns:Item(1):PreferredWidth := 50
otb2:Columns:Item(2):PreferredWidth := 400
__text := 'Cliente : '
otb2:Cell(1, 1):Range:Font:Name := "Arial"
otb2:Cell(1, 1):Range:Font:Size := 10
otb2:Cell(1, 1) := __text
otb2:Cell(1, 1):Range:Select()
oWord:Selection:MoveRight(wdCell,1)
__text := alltrim(cli->nome)
otb2:Cell(1, 2):Range:Font:Name := "Arial"
otb2:Cell(1, 2):Range:Font:Size := 10
otb2:Cell(1, 2) := __text
otb2:Cell(1, 2):Range:Select()
oWord:Selection:MoveLeft(wdCell,1)
__text := ''
otb2:Cell(2, 1):Range:Font:Name := "Arial"
otb2:Cell(2, 1):Range:Font:Size := 10
otb2:Cell(2, 1) := __text
otb2:Cell(2, 1):Range:Select()
oWord:Selection:MoveRight(wdCell,1)
__text := alltrim(cli->end) + ' - ' + alltrim(cli->bai)
__text += ' , ' + alltrim(cli->cid) + ' , ' + cli->uf
__text += ' - CEP : ' + alltrim(cli->cep)
otb2:Cell(2, 2):Range:Font:Name := "Arial"
otb2:Cell(2, 2):Range:Font:Size := 8
otb2:Cell(2, 2) := __text
otb2:Cell(2, 2):Range:Select()
oWord:Selection:MoveLeft(wdCell,1)
__text := 'Contato : '
otb2:Cell(3, 1):Range:Font:Name := "Arial"
otb2:Cell(3, 1):Range:Font:Size := 8
otb2:Cell(3, 1) := __text
otb2:Cell(3, 1):Range:Select()
oWord:Selection:MoveRight(wdCell,1)
__text := alltrim(cli->contato)
otb2:Cell(3, 2):Range:Font:Name := "Arial"
otb2:Cell(3, 2):Range:Font:Size := 8
otb2:Cell(3, 2) := __text
otb2:Cell(3, 2):Range:Select()
oWord:Selection:Collapse(wdCollapseEnd)
* Blank Line
opr4 := odoc:Paragraphs:Add() // paragrafo 4
rng4 := opr4:Range
rng4:Select()
oWord:Selection:Collapse(wdCollapseEnd)
* Order Table Instruction and Button
opr5 := odoc:Paragraphs:Add() // paragrafo 5
rng5 := opr5:Range
otb3 := odoc:Tables:Add(rng5, 1, 2)
otb3:Select()
oWord:Selection:Cells:VerticalAlignment := wdCellAlignVerticalCenter
otb3:Borders:OutsideLineStyle := wdLineStyleNone
otb3:Borders:InsideLineStyle := wdLineStyleNone
otb3:Rows:Item(1):Height := 16
otb3:Columns:Item(1):PreferredWidth := 350
otb3:Columns:Item(2):PreferredWidth := 100
__mens := 'Eventuais altera‡äes de quantidades podem ser feitas na
Col. "Qtde. Alt.".'
__mens += chr(13) + chr(10)
__mens += 'Em caso de altera‡äes, para atualizar Tab. Pedido basta
clicar botÆo "Atualizar Pedido".'
__mens := hb_oemtoansi(__mens)
otb3:Cell(1, 1):Range:Font:Name := "Arial"
otb3:Cell(1, 1):Range:Font:Size := 8
otb3:Cell(1, 1):Range:Font:Bold := wdToggle
otb3:Cell(1, 1) := __mens
otb3:Cell(1, 1):Range:Select()
oWord:Selection:MoveLeft(wdCell,1)
* Command Button Def.
rngb := otb3:Cell(1, 2):Range
rngb:Select()
oWord:Selection:ParagraphFormat:Alignment := wdAlignParagraphRight
obot := rngb:InLineshapes:AddOLEControl("Forms.CommandButton.1")
ocmd := obot:OLEFormat:Object
ocmd:Font:Name := "Verdana"
ocmd:Font:Size := 9
ocmd:Caption := " Atualizar Pedido "
ocmd:ForeColor := "&H808000"
ocmd:BackColor := "&HC0FFFF"
ocmd:AutoSize := .t.
* Command Button "on click" Sub
scode := 'Private Sub CommandButton1_Click()' + chr(13) + chr(10)
scode += 'Word.ActiveDocument.UnProtect("hu")' + chr(13) + chr(10)
scode += 'Word.ActiveDocument.Tables.Item(4).Columns.Item(7).Select' +
chr(13) + chr(10)
scode += 'Selection.Fields.Update' + chr(13) + chr(10)
scode += 'Selection.Collapse(wdCollapseEnd)' + chr(13) + chr(10)
scode += 'Word.ActiveDocument.Protect Type:=
wdAllowOnlyFormFields,NoReset:=True,Password:="hu"' + chr(13) + chr
(10)
scode += 'End Sub'
scode := hb_oemtoansi(scode)
odoc:VBProject:VBComponents:Item(1):CodeModule:AddFromString(scode)
oWord:Selection:Collapse(wdCollapseEnd)
* Linha em branco
opr6 := odoc:Paragraphs:Add() // paragrafo 6
rng6 := opr6:Range
rng6:Select()
oWord:Selection:Collapse(wdCollapseEnd)
* Order Table Header array
vcab := {}
aadd(vcab,'Codigo Mercado') // esquerda
aadd(vcab,'Marca') // centro
aadd(vcab,'FOB US$') // direita
aadd(vcab,'Qtde.') // direita
aadd(vcab,'Total US$') // direita
aadd(vcab,'Qtde. Alt.') // direita
aadd(vcab,'Total Alt. US$') // direita
* Order Table Def.
oprA := odoc:Paragraphs:Add() // paragrafo 10 , Tab3
rngA := oprA:Range
* Definicao linhas e colunas tabela
nrow := len(vtbl)
ncol := len(vcab)
* 1 linha cab.
*
otb4 := odoc:Tables:Add(rngA,nrow+1,ncol)
otb4:Borders:OutsideLineStyle := wdLineStyleSingle
otb4:Borders:InsideLineStyle := wdLineStyleSingle
otb4:Select()
oWord:Selection:Cells:VerticalAlignment := wdCellAlignVerticalCenter
* Order Table Header
for ic = 1 to ncol
__text := vcab[ic]
otb4:Cell(1,ic):Range:Font:Name := "Arial"
otb4:Cell(1,ic):Range:Font:Size := 9
otb4:Cell(1,ic):Range:Font:Bold := wdToggle
otb4:Cell(1,ic) := __text
otb4:Columns:Item(ic):Select()
if ic = 1
otb4:Columns:Item(ic):PreferredWidth := 100
oWord:Selection:ParagraphFormat:Alignment :=
wdAlignParagraphLeft
elseif ic = 2
otb4:Columns:Item(ic):PreferredWidth := 50
oWord:Selection:ParagraphFormat:Alignment :=
wdAlignParagraphCenter
else
otb4:Columns:Item(ic):PreferredWidth := 70
oWord:Selection:ParagraphFormat:Alignment :=
wdAlignParagraphRight
endi
oWord:Selection:Collapse(wdCollapseEnd)
next
* Order Table
for i = 1 to nrow
for j = 1 to ncol
otb4:Cell(i+1,j):Range:Font:Name := "Courier New"
otb4:Cell(i+1,j):Range:Font:Size := 8
if j <= ncol-2
__text := vtbl[i,j]
otb4:Cell(i+1,j) := __text
elseif j = ncol-1
crng := otb4:Cell(i+1,j):Range
odoc:FormFields:Add(crng,wdFieldFormTextInput)
else
formula := "="
formula += "C" + alltrim(tran(i+1,'999'))
formula += "*"
formula += "F" + alltrim(tran(i+1,'999'))
otb4:Cell(i+1,j):Formula(formula,"0,00")
endi
next
next
*
otb4:Cell(nrow+1,ncol):Range:Select()
oWord:Selection:Collapse(wdCollapseEnd)
oWord:ActiveDocument:Protect(wdAllowOnlyFormFields,.t.,"hu")
inkey(0)
odoc:SaveAS("C:\test\test.doc")
odoc:Close()
oWord:Quit()
return NIL
30 Mai 2013 00:22
I am attempting to insert an image (picture file) into a table cell in a
word document programatically.
The code I have thus far is :
**************************
local oWord, oDoc, oRng, oTbl, oCel
if ( oWord := createobject("Word.Application") ) != nil
oWord:Visible := .f.
oDoc := oWord:Documents:Add()
oRng := oDoc:Range(0,1)
oTbl := oDoc:Tables:Add(oRng,3,3)
oCel := oTbl:Cell(2,2)
* need to Insert image into oCel here
oDoc:Close()
endif
Thanks for any suggestions
Gene
***************************
Try
oDoc:InlineShapes:AddPicture( "your image with full path", .F., .T.,
oCel:Range )
Thank you Enrico! Worked great!
Regards,
Gene
30 Mai 2013 00:30
30 Mai 2013 21:18
31 Mai 2013 08:17
Sim claro, é muito bom ver exemplos.Hasse escreveu:Se houver interesse posso avançar no assunto.
31 Mai 2013 14:19
*
*
*==================================================================================================
FUNCTION Main() // PRT_CBSUL()
*
SET DATE FORMAT TO "DD/MM/YYYY"
SET EPOCH TO 1901
*
REQUEST HB_CODEPAGE_PT850
HB_SetCodePage( "PT850" )
*
REQUEST DBFCDX
RddSetDefault("DBFCDX")
*
c_Arq1 := "_Contrato_CBSUL_01.rtf" // c_ServPath + "\_Contrato_CBSUL_01.rtf"
c_Arq2 := "_Contr_CBSUL.rtf" // c_LocalPath + "\_Contr_CBSUL.rtf"
c_Data := DtoC( Date() )
*
IF File( c_Arq1 )
FileCopy( c_Arq1, c_Arq2 )
SetFAttr( c_Arq2, 0 )
c_Contrato := MemoRead( "_Contrato_CBSUL_01.rtf" )
ELSE
Alert( 'O arquivo "_Contr_CBSUL.rtf" est faltando no servidor. ;;Verifique !!!;;' +;
'ImpressÆo cancelada.')
RETURN( NIL )
ENDIF
*
c_NomDev := "Edson Machado da Silva Borges Medina" // ALLTRIM( CADASTRO->NOME )
c_CpfCnpj := "111.222.333/0001-44" // ALLTRIM( CADASTRO->CGC_CPF )
c_Ident := "5.666.777-8" // ALLTRIM( CADASTRO->IDENT )
*
IF EMPTY( c_CpfCnpj )
ALERT( 'Falta o CPF/CNPJ do cliente ;== ' + c_NomDev + ' ==;Providenciar;;EmissÆo do Contrato Cancelado.' )
RETURN( .F. )
ENDIF
*
IF EMPTY( c_Ident ) .AND. "CPF-" $ c_CpfCnpj
ALERT( 'Falta a IDENTIDADE do cliente ;== ' + c_NomDev + ' ==; Providenciar;;EmissÆo do Contrato Cancelado.' )
RETURN( .F. )
ENDIF
*
c_NomDev := HB_OemToAnsi( c_NomDev )
c_CpfCnpj := STRTRAN( c_CpfCnpj, "CPF-", "" )
*
c_Contrato := STRTRAN( c_Contrato, "#@NomDev@#", c_NomDev )
c_Contrato := STRTRAN( c_Contrato, "#@NumCPF@#", c_CpfCnpj )
c_Contrato := STRTRAN( c_Contrato, "#@NumIdent@#", c_Ident )
c_Contrato := STRTRAN( c_Contrato, "#@DtContr@#", c_Data )
*
MemoWrit( "_Contr_CBSUL.rtf", c_Contrato )
*
cRoda2 := 'START "C:\Arquivos de programas\Microsoft Office\OFFICE11\winword.exe" _Contr_CBSUL.rtf'
*
RUN( cRoda2 )
*
RETURN( NIL )