Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Boston, Massachusetts, USA
    Posts
    205
    Thanks
    0
    Thanked 0 Times in 0 Posts

    macro to specify number (VBA Office XP)

    I hope I can explain this properly. I have one page coversheet for legal exhibits. I have been asked to create a macro that asks the user how many of these sheets needs to be created and then inserts that many pages into the document and numbers each one (exhibit 1, exhibit 2, etc). I also need to ask the user if they want the exhibits numbered 1,2,3 or a,b,c. I know that I need to use SEQ codes for this but can't get my head around where to start or what the code needs to be like. Can anyone help????

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: macro to specify number (VBA Office XP)

    What if you cheat a bit... Put the text in the header, use a page number code for the exhibit number, and just insert page breaks for each desired page. The only hard part is that you need to insert a switch into the page number code that tells it whether to use regular numbers or regular letters. Or you could save one of each as an AutoText, and insert the AutoText desired by the user.

    But... to use SEQ fields, perhaps something like this:

    <pre>Sub MakePages()
    Dim intNumExhibits As Integer, strNumStyle As String, intCounter As Integer
    intNumExhibits = CInt(InputBox("How many exhibit cover sheets would you like?"))
    If MsgBox("Use letters instead of numbers?", vbYesNo) = vbYes Then
    strNumStyle = "* Alphabetic"
    Else
    strNumStyle = "* Arabic"
    End If
    For intCounter = 1 To intNumExhibits
    With Selection
    .TypeText "Exhibit "
    .Fields.Add .Range, wdFieldSequence, "Exhibit " & strNumStyle
    If intCounter < intNumExhibits Then
    .InsertBreak wdPageBreak
    End If
    End With
    Next
    End Sub</pre>

    When I try this in Word 2002, I get a "bonk" noise after the InputBox, but I can't tell what's causing it. Hmmm... maybe specifying an icon for the MsgBox would fix that.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Boston, Massachusetts, USA
    Posts
    205
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: macro to specify number (VBA Office XP)

    Thanks. That gave me the basis I needed. I ended up using a collection of auto text entries to build a series of documents based on choices on a userform, but this was the basis of the code. Thanks!!!!

Posting Permissions

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