Consulting

Results 1 to 3 of 3

Thread: Saving a word document

  1. #1

    Post Saving a word document

    I have a word document that i need to duplicate 200 times with the filename ending in consecutive numbers.

    file1
    file2
    file3....file200

    thanks

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Try something based on:
    Sub Make200()
    Application.ScreenUpdating = False
    Dim i As Long, StrPath As String, StrExt As String, lFmt As Long
    With ActiveDocument
      StrPath = .Path & "\":   lFmt = .SaveFormat
      StrExt = "." & Split(.Name, ".")(UBound(Split(.Name, ".")))
      For i = 1 To 200
        .SaveAs2 FileName:=StrPath & Format(i, "000") & StrExt, _
          Fileformat:=lFmt, AddToRecentFiles:=False
      Next
    End With
    Application.ScreenUpdating = True
    End Sub
    If you need to prefix the number with some text, simply add that after the '\' in:
    StrPath = .Path & "\"

    Note: The code assumes the active document is the one you want to replicate.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Thank you!
    Does exactly what I wanted.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •