Hi all.
I'm Italian. Sorry for my bad English.
First: I do not know to program in vba word and write what I derived from the macro recorder and the Internet.
In my code I open a doc file, edit the footer and print the document.
I do it with this code:
Code:
nomefiletab = (Trim(Testo99.Value & "")) + "\" + Right("000" + Trim(CasellaCombinata34 & ""), 3) + "_test.DOC"
If FileEsiste3(nomefiletab) Then
For nco = 1 To Val(tabst2co)
piepag = ""
piepag = "TEST - Allegato " & trim(str(nco))
Set objWord = New Word.Application
Set wDoc = objWord.Documents.Open(nomefiletab)
' cancella il pie' di pagina vecchio
objWord.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
objWord.Selection.ParagraphFormat.Alignment = wdAlignParagraphRight
objWord.Selection.Delete Unit:=wdCharacter, Count:=1
objWord.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
objWord.Selection.EndKey Unit:=wdLine, Extend:=wdExtend
objWord.Selection.Delete Unit:=wdCharacter, Count:=1
objWord.ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
' aggiunge il pie' di pagina nuovo
objWord.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
objWord.Selection.ParagraphFormat.Alignment = wdAlignParagraphRight
objWord.Selection.Font.Name = "Courier New"
objWord.Selection.Font.Size = 7
objWord.Selection.Font.Bold = True
objWord.Selection.TypeText Text:=piepag
objWord.ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
' objWord.ActiveDocument.ActiveWindow.Activate
objWord.Application.WindowState = wdWindowStateMinimize
wDoc.Activate
objWord.Visible = True
'objWord.ActiveDocument.PrintPreview
' stampa il documento
wDoc.PrintOut
wDoc.Close
objWord.Quit SaveChanges:=wdDoNotSaveChanges
Set objWord = Nothing
Set wDoc = Nothing
Next nco
S2OK.Visible = True
endif
Well if I go to print preview ('objWord.ActiveDocument.PrintPreview) everything works, if I use printout print the first page of the document!
I do not know how to solve.
Someone can 'help me?
thanks