Hi kar64,
Try the following - it should be much more efficient:
Code:
Dim objWord As Word.Application
Dim wDoc As Word.Document
nomefiletab = Trim(Testo99.Value) & "\" & Right("000" + Trim(CasellaCombinata34), 3) & "_test.DOC"
If Dir(nomefiletab) <> "" Then
Set objWord = New Word.Application
objWord.Visible = True
For nco = 1 To Val(tabst2co)
piepag = "TEST - Allegato " & Trim(CStr(nco))
Set wDoc = objWord.Documents.Open(nomefiletab, AddToRecentFiles:=False)
With wDoc
With .Sections.First.Footers(wdHeaderFooterPrimary).Range
'cancella il pie' di pagina vecchio & aggiunge il pie' di pagina nuovo
.Text = piepag
.ParagraphFormat.Alignment = wdAlignParagraphRight
With .Font
.Name = "Courier New"
.Size = 7
.Bold = True
End With
End With
' stampa il documento
.PrintOut Range:=wdPrintAllDocument
.Close SaveChanges:=wdDoNotSaveChanges
End With
Next nco
objWord.Quit
Set wDoc = Nothing: Set objWord = Nothing
S2OK.Visible = True
End If