Macro that inserts Listnum field with specific start number

M

MarieJ

Hi,
I'm trying to insert Listnum fields, but the start number needs to be
whatever the user types in the user form. Apparently I can't use variables
pointing to the value of the text box on the user form inside the field code
after the /s switch. Any ideas how I can accomplish this?

TIA mariej
 
D

Doug Robbins - Word MVP

Use

ActiveDocument.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
Text:="LISTNUM " & Chr(34) & "MyList" & Chr(34) & " \s " & txtStartNum.Text

Assuming that the starting number is entered into a control with the name of
txtStartNum
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
M

MarieJ

Hi Doug.
Thanks for the reply.
I'm getting an Object is Required error when I try adapting the code you sent.

Here's the macro I recorded that makes the start number 100. The place
where "100" is is where I need the txtstartnum.text number. Can you tweak
what I have - I have tried all kinds of iterations using your example and
continue to get the error.

Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
Text:="LISTNUM StockCert \l 1 \s 100 ", PreserveFormatting:=False

Thanks. mariej
 
M

MarieJ

Well, it was a typo in the text box name. Silly me. I have it working now.
Thank you so much!
 

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