![]() |
|
#9
|
||||
|
||||
|
Hi ahrinn, to create a document with fully-random numbers being generated automatically upon opening:
• create the document; • press Alt-F11 to open the vba environment; • on the left you'll see your document's name. Expand that and you'll see a 'ThisDocument' entry. Double-click on that. • in the 'ThisDocument' module, insert the following code - Code:
Private Sub Document_Open()
Call UpdateRandomNumber
End Sub
Sub UpdateRandomNumber()
Randomize Timer
With ActiveDocument
.CustomDocumentProperties("RandNum").Value = Format(Int(1000000 * Rnd), "000000")
.Fields.Update
End With
End Sub
• add a numeric custom document property named 'RandNum' to your document, with a value of 0. To do this, use the Pizza Button, then choose Properties|Advanced|Custom. • wherever you want the random numbers to appear, insert a DOCPPROPERTY field coded as {DOCPPROPERTY RandNum}, where the field braces (ie '{}') are created via Ctrl-F9.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| random pop up wont go away | 464646 | OneNote | 0 | 05-01-2012 04:34 AM |
| how can i make random variant | neezeen | Word | 0 | 11-22-2011 08:08 AM |
| Random number generator for Powerpoint 2011 | kala85 | PowerPoint | 0 | 11-19-2011 06:16 AM |
Visio random crash?
|
maxoys45 | Visio | 5 | 10-25-2010 09:15 AM |
Random names from a given list
|
professor snape | Excel | 1 | 06-06-2009 09:39 AM |