View Single Post
 
Old 02-14-2013, 08:36 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote