Numbered new documents...

A

Al & Cay Grant

Hi Folks,

I have a a series of people that are in a listbox. For each person in the
listbox I want to create a new document based on a template, which can be
referred to - see below and see what I mean;

If CheckBox2.Value = True Then
For w = 0 To a ' Counts number of people
Documents.Add Template:="C:\Documents and Settings\User\Application
Data\Microsoft\Templates\Labels.dot"
Set LabelsDoc(w) = ActiveDocument
End If

Set LabelsDoc(w)=ActiveDocument is the line that I wont work of course. How
would one go about having LabelsDoc1, LabelsDoc2, LabelsDoc3 etc......

Cheers

-Al
 
A

Al & Cay Grant

PS: Anyone know how to count the total number of selected items in a list
box without looping through the lot?

Something like:

ListBox1.Selected.Count ?

TIA

-Al
 
D

Doug Robbins - Word MVP

Hi Al,

I am not sure why you would be creating a different document object for each
person. I believe that it would be more normal to dim a variable to hold
the document then use

Dim LabelsDoc as Document
For w = 0 to a 'Note a must be variable holding a numeric value
Set LabelsDoc = Documents.Add(Template: = etc
'do whatever else you want to do with LabelsDoc
LabelsDoc.SaveAs "drive:\path\filename" 'Include the counter in the
filename if that's what you want.
LabelsDoc.Close
Set LabelsDoc=Nothing
Next w

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top