gerar arquivos em word usando harbour
Moderador: Moderadores
- Pablo César
- Usuário Nível 7

- Mensagens: 5312
- Registrado em: 31 Mai 2006 10:22
- Localização: Curitiba - Paraná
gerar arquivos em word usando harbour
Fantastico !
Obrigado Hasse por compartilhar conosco !
:)Pos
Obrigado Hasse por compartilhar conosco !
:)Pos
Um clip-abraço !
Pablo César Arrascaeta
Compartilhe suas dúvidas e soluções com todos os colegas aqui do fórum.
Evite enviar as dúvidas técnicas por MPs ou eMails, assim todos iremos beneficiar-nos.
Pablo César Arrascaeta
Compartilhe suas dúvidas e soluções com todos os colegas aqui do fórum.
Evite enviar as dúvidas técnicas por MPs ou eMails, assim todos iremos beneficiar-nos.
-
Hasse
- Usuário Nível 4

- Mensagens: 820
- Registrado em: 19 Out 2004 10:30
- Localização: Jaraguá do Sul - SC
gerar arquivos em word usando harbour
Partindo de um Mestre considero esta avaliação como um grande elogio.
Obrigado.
Obrigado.
Hasse
CP200 / CP500 / Basic / dBase III / dBase IV / Clipper Summer / RTlink / Exospace.
Clipper 5.3b / Blinker 7.0 / CDX com TAG
xHarbour 1.2.1-6604 / Borland C++ (5.5.1) 32 bit / HBmake.
Harbour 3.2.0dev (r1412121623) / MINGW / HBM2 / MiniGui HMG 3.1.4 / IDE (Roberto Lopez).
"Conheça todas as teorias, domine todas as técnicas, mas, quando tocares uma alma humana, seja apenas outra alma humana." (C.G.Jung)
CP200 / CP500 / Basic / dBase III / dBase IV / Clipper Summer / RTlink / Exospace.
Clipper 5.3b / Blinker 7.0 / CDX com TAG
xHarbour 1.2.1-6604 / Borland C++ (5.5.1) 32 bit / HBmake.
Harbour 3.2.0dev (r1412121623) / MINGW / HBM2 / MiniGui HMG 3.1.4 / IDE (Roberto Lopez).
"Conheça todas as teorias, domine todas as técnicas, mas, quando tocares uma alma humana, seja apenas outra alma humana." (C.G.Jung)
- Amparo
- Usuário Nível 3

- Mensagens: 342
- Registrado em: 20 Ago 2010 10:38
- Localização: caieiras / sao paulo
gerar arquivos em word usando harbour
ola amigos
Hasse, eu nao sei nem o que falar...
voce nao pode imaginar o quanto estou feliz em conseguir emitir um contrato em meu sistema feito em puro Harbour no formato do word, sao pessoa como voce o Pablo o Itamar o Rochinha e outros que nao me lembro o nome agora, mas que a cada dia merecem aplausos e mais aplausos.
muito mais muito obrigado mesmo, espero um dia por estar a altura de voces e poder ajudar outros que tambem necessitam.
abraços
Amparo.
Hasse, eu nao sei nem o que falar...
voce nao pode imaginar o quanto estou feliz em conseguir emitir um contrato em meu sistema feito em puro Harbour no formato do word, sao pessoa como voce o Pablo o Itamar o Rochinha e outros que nao me lembro o nome agora, mas que a cada dia merecem aplausos e mais aplausos.
muito mais muito obrigado mesmo, espero um dia por estar a altura de voces e poder ajudar outros que tambem necessitam.
abraços
Amparo.
-
Hasse
- Usuário Nível 4

- Mensagens: 820
- Registrado em: 19 Out 2004 10:30
- Localização: Jaraguá do Sul - SC
gerar arquivos em word usando harbour
Fico especial e duplamente satisfeito com esta tua vibrante satisfação e alegria.
Aqui estaremos sempre às ordens para nos ajudarmos mutuamente. Fui muito auxiliado no meu início com o xHarbour, e agora procuro retribuir da melhor forma possível.
E ainda preciso de auxílio, agora que estou dando os primeiros passos na MiniGUI. Ou seja, sempre aprendendo...
Aqui estaremos sempre às ordens para nos ajudarmos mutuamente. Fui muito auxiliado no meu início com o xHarbour, e agora procuro retribuir da melhor forma possível.
E ainda preciso de auxílio, agora que estou dando os primeiros passos na MiniGUI. Ou seja, sempre aprendendo...
Hasse
CP200 / CP500 / Basic / dBase III / dBase IV / Clipper Summer / RTlink / Exospace.
Clipper 5.3b / Blinker 7.0 / CDX com TAG
xHarbour 1.2.1-6604 / Borland C++ (5.5.1) 32 bit / HBmake.
Harbour 3.2.0dev (r1412121623) / MINGW / HBM2 / MiniGui HMG 3.1.4 / IDE (Roberto Lopez).
"Conheça todas as teorias, domine todas as técnicas, mas, quando tocares uma alma humana, seja apenas outra alma humana." (C.G.Jung)
CP200 / CP500 / Basic / dBase III / dBase IV / Clipper Summer / RTlink / Exospace.
Clipper 5.3b / Blinker 7.0 / CDX com TAG
xHarbour 1.2.1-6604 / Borland C++ (5.5.1) 32 bit / HBmake.
Harbour 3.2.0dev (r1412121623) / MINGW / HBM2 / MiniGui HMG 3.1.4 / IDE (Roberto Lopez).
"Conheça todas as teorias, domine todas as técnicas, mas, quando tocares uma alma humana, seja apenas outra alma humana." (C.G.Jung)
- Amparo
- Usuário Nível 3

- Mensagens: 342
- Registrado em: 20 Ago 2010 10:38
- Localização: caieiras / sao paulo
gerar arquivos em word usando harbour
ola pessoal
tudo bem com vcs...
preciso novamente da ajuda dos colenas, esta aparecendo um erro ao abrir e imprimir um arquivo RTF no word
abaixo a linha completa da procedure
e aparece o seguinte erro:
Erro TOleAuto/-1 0x80080005: TOLEAUTO:NEW
Erro DOS nÆo dispon¡vel
se eu der dois cliques no arquivo RTF ele abre o WORD com todos os dados corretamente, ja tentei alterar a linha do prg colocando assim:
oWord:=TOleAuto():New( "WinWord.Application" )
ai da outro erro:
Erro TOleAuto/-1 CO_E_CLASSSTRING: TOLEAUTO:NEW
Erro DOS nÆo dispon¡vel
alguem tem ideia do que pode ser?
tudo bem com vcs...
preciso novamente da ajuda dos colenas, esta aparecendo um erro ao abrir e imprimir um arquivo RTF no word
abaixo a linha completa da procedure
Código: Selecionar todos
Procedure IMPRIME_WORD( CARQ )
Local oWord
oWord:=TOleAuto():New( "Word.Application" )
oWord:Documents:Open( CARQ )
oWord:WindowState := 1
oWord:Visible := .t.
oWord:PrintOut() //PARA IMPRIMIR DIRETO
ReturnErro TOleAuto/-1 0x80080005: TOLEAUTO:NEW
Erro DOS nÆo dispon¡vel
se eu der dois cliques no arquivo RTF ele abre o WORD com todos os dados corretamente, ja tentei alterar a linha do prg colocando assim:
oWord:=TOleAuto():New( "WinWord.Application" )
ai da outro erro:
Erro TOleAuto/-1 CO_E_CLASSSTRING: TOLEAUTO:NEW
Erro DOS nÆo dispon¡vel
alguem tem ideia do que pode ser?
- rochinha
- Administrador

- Mensagens: 4664
- Registrado em: 18 Ago 2003 20:43
- Localização: São Paulo - Brasil
- Contato:
gerar arquivos em word usando harbour
Amiguinhos,
Vale a pena relembrar MERGE - Colagem de dados via Command Line.
No caso do acesso via OLE cabe-se usar CreateObject( "Word.Application" ) ou Win_CreateObject( "Word.Application" ) no lugar de TOLEAuto():New( "Word.Application" ).
Quando sabemos qual a versão de nossos Offices podemos reforçar a forma de chamada assim:
( "Word.Application.8" ) // Para versão 8
( "Word.Application.10" ) // Para versão 10
( "Word.Application.11" ) // Para versão 11
etc.
Vale a pena relembrar MERGE - Colagem de dados via Command Line.
No caso do acesso via OLE cabe-se usar CreateObject( "Word.Application" ) ou Win_CreateObject( "Word.Application" ) no lugar de TOLEAuto():New( "Word.Application" ).
Quando sabemos qual a versão de nossos Offices podemos reforçar a forma de chamada assim:
( "Word.Application.8" ) // Para versão 8
( "Word.Application.10" ) // Para versão 10
( "Word.Application.11" ) // Para versão 11
etc.
OPS! LINK QUEBRADO? Veja ESTE TOPICO antes e caso não encontre ENVIE seu email com link do tópico para [url=mailto://fivolution@hotmail.com]fivolution@hotmail.com[/url]. Agradecido.
@braços : ? )
A justiça divina tarda mas não falha, enquanto que a justiça dos homens falha porque tarda.
@braços : ? )
A justiça divina tarda mas não falha, enquanto que a justiça dos homens falha porque tarda.
gerar arquivos em word usando harbour
Pessoal, estou precisando criar um arquivo do Word por meio de minha aplicação em Harbour. Pesquisando no fórum, achei este post. Testei os exemplos acima, mas não consegui nem compilá-los.
Agradeceria se alguém poderia dar dicas para um iniciante. É um arquivo simples, só com texto, mas preciso de mínimas formatações do Word, nada complexo.
Qualquer ajuda é bem vinda.
Agradeceria se alguém poderia dar dicas para um iniciante. É um arquivo simples, só com texto, mas preciso de mínimas formatações do Word, nada complexo.
Qualquer ajuda é bem vinda.
Inacio de Carvalho Neto
- sygecom
- Administrador

- Mensagens: 7131
- Registrado em: 21 Jul 2006 10:12
- Localização: Alvorada-RS
- Contato:
gerar arquivos em word usando harbour
Inacio,
Post os erros que está dando ao compilar
Post os erros que está dando ao compilar
Leonardo Machado
xHarbour.org + Hwgui + PostgreSql
xHarbour.org + Hwgui + PostgreSql
gerar arquivos em word usando harbour
Primeiro está dando erro nesta linha:
Imagino que esteja faltando alguma lib.
Daí eu comentei essa linha, só que daí dá vários erros de compilação, especialmente nas linhas que têm:
Agradeço toda ajuda.
Código: Selecionar todos
#include 'winpar.ch' -> Define for Windows variables wd...Daí eu comentei essa linha, só que daí dá vários erros de compilação, especialmente nas linhas que têm:
Código: Selecionar todos
otb2:Cell(1, 1) := __textInacio de Carvalho Neto
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
gerar arquivos em word usando harbour
cjp escreveu:Imagino que esteja faltando alguma lib.
Código: Selecionar todos
#include "winpar.ch"
Se está dando erro, é porque não existe o arquivo winpar.ch
Se isso vém de uma LIB ou não, ou se vai precisar de mais coisas, aí já é outra história.
Ou se está do jeito que escreveu.... talvez esteja escrito errado.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
gerar arquivos em word usando harbour
De fato, o arquivo winpar.ch não existe no meu computador.
Se ele é de alguma lib, qual seria? E como a obtenho?
Se estiver escrito errado, não fui eu que escrevi, só copiei o que está neste post.
Se ele é de alguma lib, qual seria? E como a obtenho?
Se estiver escrito errado, não fui eu que escrevi, só copiei o que está neste post.
Inacio de Carvalho Neto
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
gerar arquivos em word usando harbour
Código: Selecionar todos
#include 'winpar.ch' -> Define for Windows variables wd...
Se não tiver outro jeito, na Microsoft tem todos as constantes/#defines
Mas é uma lista gigantesca, milhares.
Pode compilar usando -w3 -es2 e digitar somente o que o fonte precisar.
Seria interessante, talvez, alterar pra "office.ch" e deixar tudo em maiúsculas como é o padrão do Harbour/Clipper.
https://docs.microsoft.com/pt-br/office ... dlinestyle
por exemplo, alguns dessa página:
Código: Selecionar todos
#define WDLINESTYLEDASHDOT 0,5
#define WDLINESTYLEDASHDOTDOT 6
Ou verifique nas LIBs GUI se tem algum exemplo, e se tem arquivo equivalente.
Ou algum kit SDK da Microsoft que tenha isso.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- sygecom
- Administrador

- Mensagens: 7131
- Registrado em: 21 Jul 2006 10:12
- Localização: Alvorada-RS
- Contato:
gerar arquivos em word usando harbour
Olhei todos os post aqui não tem nenhum com: #include 'winpar.ch', de onde você tirou isso ? por que colocou no seu código ? Post o exemplo completo que está tentando compilar.cjp escreveu:Primeiro está dando erro nesta linha:
Imagino que esteja faltando alguma lib.Código: Selecionar todos
#include 'winpar.ch' -> Define for Windows variables wd...
Daí eu comentei essa linha, só que daí dá vários erros de compilação, especialmente nas linhas que têm:
Agradeço toda ajuda.Código: Selecionar todos
otb2:Cell(1, 1) := __text
Leonardo Machado
xHarbour.org + Hwgui + PostgreSql
xHarbour.org + Hwgui + PostgreSql
gerar arquivos em word usando harbour
Segue meu código completo, exatamente como retirei do post acima:
Código: Selecionar todos
function main
*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...
table_form()
******************************************************************************
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 NILInacio de Carvalho Neto
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
gerar arquivos em word usando harbour
Quando o Itamar postou o fonte, postou também a origem, o link no fórum do google.
Se é pra olhar como fica... melhor procurar outro exemplo.
Se realmente for mexer, pode usar o link de origem da mensagem e pedir o arquivo.
Se é pra olhar como fica... melhor procurar outro exemplo.
Se realmente for mexer, pode usar o link de origem da mensagem e pedir o arquivo.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
