View Single Post
  #10   Report Post  
cjobes
 
Posts: n/a
Default

Cindy,

Thanks for answering. Here is a quick sum of what I have and what I'm trying
to do:

I have a one-page document with 80 boxes. I added the following code (see
below) to it and then made it a DOT file. What I would like to get to is
giving the user a chance of putting not only the starting number but also
the ending number into a third box. I would then change the code to call a
second, third, fourth page after each 80 numbers. What I'm looking for is
help how to add as many pages in the code as needed with those 80 boxes.
When I issue a wdPageBreak only a blank page comes up. I'm a DB and App guy
and haven't work much with Word automation.

Here is the code again:

Dim Client As String
Dim stNum As Integer
Dim test As String
Dim pages As Integer

Selection.HomeKey Unit:=wdStory
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Client = InputBox("Please enter Client name")
stNum = CInt(InputBox("Please enter 1st client file number"))
pages = CInt(InputBox("Please enter the number of pages"))
Client = Client + "-"


Selection.HomeKey Unit:=wdStory

i = stNum
While pages 0
While i stNum + 80
If i 10 Then test = "00000"
If i 10 And i 100 Then test = "0000"
If i 100 And i 1000 Then test = "000"
If i 1000 And i 10000 Then test = "00"
If i 999999 Then test = "0"
Selection.TypeText Text:=Client + test
Selection.TypeText Text:=CStr(i)
Selection.MoveRight Unit:=wdCharacter, Count:=2
i = i + 1

Wend
Selection.InsertBreak Type:=wdPageBreak
pages = pages - 1
Wend


End Sub

Thanks for your help.

Claus


"Cindy M -WordMVP-" wrote in message
news:VA.0000adb8.006c102f@speedy...
Hi Cjobes,

I'm stuck with a problem. We have a 1-page template that has 80 costum
labels on it. I wrote a macro in VB that will fill in the info as

needed. I
am trying to create a continues number scheme based on the user imput.

The
VB script works fine for the first page but if the user needs more than

80
numbers I can't find a way to add a second page. When I issue a

wdPageBreak
it's just an empty space without the labels.

Assuming this is NOT mail merge (can't be sure from the discussion)...

Insert a SEQ field in each label on the page. In the very first one, add

the
\r switch so that you can set the starting number. Your script can either
edit this number in the field code. Or you can set the starting number in

a
custom document property and embed a DocProperty field code into the SEQ
field code.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)