Results 1 to 2 of 2
  1. #1

    Print one sheet of labels for all files in a dir?

    I need to print a sheet of address labels for all the files in a directory.
    I.e., I have 12 Word docs in a directory, each a letter, each addressed to a different receipient. Instead of individually opening each letter and printing an envelope separately, I'd like to be able to run a script which would pass through all the documents, extract each address and print all 12 on one label sheet.
    Is this possible?
    Thank you.

  2. #2
    3 Star Lounger
    Join Date
    Apr 2001
    Levin, Manawatu-Wanganui, New Zealand
    Thanked 28 Times in 26 Posts

    Re: Print one sheet of labels for all files in a dir?

    The following should loop thru the directory open/close each of the documents. No guarantees though.
    sub loopingLabels
    Dim FS
    Dim i As Integer
    Set FS = Application.FileSearch
    Dim strFileName()
    Application.ScreenUpdating = False

    With FS.PropertyTests
    .Add Name:="Files of Type", _
    Condition:=msoConditionFileTypeWordDocuments, _
    End With

    With FS
    ' set you path here in the lookIn statement
    .LookIn = "CataWordDocs"
    ReDim strFileName(FS.FoundFiles.Count)
    MsgBox (FS.FoundFiles.Count)'optional line

    If .Execute(SortBy:=msoSortByFileName, _
    SortOrder:=msoSortOrderAscending) > 0 Then
    For i = 1 To .FoundFiles.Count
    strFileName(i) = .FoundFiles(i)
    Documents.Open (strFileName(i))
    'do something here to make label ??
    ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
    Next i
    MsgBox "There were no files found."
    End If
    End With
    Set FS = Nothing
    End Sub
    I hope this is a starter, sorry about the do something here to make labels.
    It is all smoke & mirrors !!


Posting Permissions

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