Input Box to auto number?

C

Cottage6

I have a document that includes a table with 4 rows in it, each containing a
gift certificate. Each certificate needs to be numbered, which the code
below does without a problem. However, since (for example) only 2
certificates may be requested, is there a way to use an input box (or
something) to request just those 2 certificates and not number the other 2?
The next time certificates were requested the auto number should take up
where it left off. Any help would be greatly appreciated , as I'm pretty
lost on this one. TIA



Sub AutoNew()

Order = System.PrivateProfileString("C:\Settings3.Txt", _
"MacroSettings", "Order")

If Order = "" Then
Order = 1
Else
Order = Order + 1
End If

System.PrivateProfileString("C:\Settings3.txt", "MacroSettings", _
"Order") = Order

ActiveDocument.Bookmarks("Order").Range.InsertBefore Format(Order, "0000#")
'***********************************************************************
Order2 = System.PrivateProfileString("C:\Settings3.Txt", _
"MacroSettings", "Order")

If Order2 = "" Then
Order2 = 1
Else
Order2 = Order2 + 1
End If

System.PrivateProfileString("C:\Settings3.txt", "MacroSettings", _
"Order2") = Order2

ActiveDocument.Bookmarks("Order2").Range.InsertBefore Format(Order2, "0000#")
'********************************************************************************
Order3 = System.PrivateProfileString("C:\Settings3.Txt", _
"MacroSettings", "Order")

If Order3 = "" Then
Order3 = 1
Else
Order3 = Order2 + 1
End If

System.PrivateProfileString("C:\Settings3.txt", "MacroSettings", _
"Order3") = Order3

ActiveDocument.Bookmarks("Order3").Range.InsertBefore Format(Order3, "0000#")
'***********************************************************************************
Order4 = System.PrivateProfileString("C:\Settings3.Txt", _
"MacroSettings", "Order")

If Order4 = "" Then
Order4 = 1
Else
Order4 = Order3 + 1
End If

System.PrivateProfileString("C:\Settings3.txt", "MacroSettings", _
"Order4") = Order4

ActiveDocument.Bookmarks("Order4").Range.InsertBefore Format(Order4, "0000#")
ActiveDocument.SaveAs FileName:="Meal Tickets" & Format(Order4, "0000#")

System.PrivateProfileString("C:\Settings3.txt", "MacroSettings", _
"Order") = Order4
End Sub
 
G

Greg

Maybe something like:
Sub AutoNew()
Dim oNum As String
Dim i As Integer
Dim Order As String
Order = System.PrivateProfileString("C:\Settings.Txt", _
"MacroSettings", "Order")

oNum = InputBox("Enter a number 1 to 4")

For i = 1 To CInt(oNum)
If Order = "" Then
Order = 1
Else
Order = Order + 1
End If
System.PrivateProfileString("C:\Settings.txt", "MacroSettings", _
"Order") = Order
ActiveDocument.Bookmarks("Order" & i).Range.InsertBefore
Format(Order, "0000#")
Next
End Sub
 
G

Greg

Maybe something like:
Sub AutoNew()
Dim oNum As String
Dim i As Integer
Dim Order As String
Order = System.PrivateProfileString("C:\Settings.Txt", _
"MacroSettings", "Order")

oNum = InputBox("Enter a number 1 to 4")

For i = 1 To CInt(oNum)
If Order = "" Then
Order = 1
Else
Order = Order + 1
End If
System.PrivateProfileString("C:\Settings.txt", "MacroSettings", _
"Order") = Order
ActiveDocument.Bookmarks("Order" & i).Range.InsertBefore
Format(Order, "0000#")
Next
End Sub
 
G

Greg

Maybe something like:
Sub AutoNew()
Dim oNum As String
Dim i As Integer
Dim Order As String
Order = System.PrivateProfileString("C:\Settings.Txt", _
"MacroSettings", "Order")

oNum = InputBox("Enter a number 1 to 4")

For i = 1 To CInt(oNum)
If Order = "" Then
Order = 1
Else
Order = Order + 1
End If
System.PrivateProfileString("C:\Settings.txt", "MacroSettings", _
"Order") = Order
ActiveDocument.Bookmarks("Order" & i).Range.InsertBefore
Format(Order, "0000#")
Next
End Sub
 

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