Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
I have put a txt box and a label in a word doc. I am trying to populate it
with code that I have written to generate a random number and I am not having any luck. Is there a property that I am not aware of for labels and txt boxes in word. For all I know it could be my Option Explicit code at the top. Here is my code: It starts in the Word Project: Option Explicit Public Function GenPrimaryValue() As String Dim strStart As String Dim strDate As String Dim strEnd As String Dim CrntDate As Date Dim intChar As Integer Dim upperbound As Long Dim lowerbound As Long Dim X As Long Randomize CrntDate = Now upperbound = 65 lowerbound = 89 intChar = CInt((upperbound - lowerbound + 1) * Rnd + lowerbound) strStart = Chr(intChar) strDate = DatePart("YYYY", CrntDate) strDate = strDate & Format(DatePart("m", CrntDate), "00") strDate = strDate & Format(DatePart("d", CrntDate), "00") strEnd = "" For X = 1 To 5 upperbound = 0 lowerbound = 4 intChar = CInt((upperbound - lowerbound + 1) * Rnd + lowerbound) Select Case intChar Case 1 upperbound = 65 lowerbound = 89 intChar = CInt((upperbound - lowerbound + 1) * Rnd + lowerbound) Case Else upperbound = 51 lowerbound = 48 intChar = CInt((upperbound - lowerbound + 1) * Rnd + lowerbound) End Select strEnd = strEnd & Chr(intChar) Next X GenPrimaryValue = strStart & strDate & strEnd PRONUM = GenPrimaryValue End Function Private Sub Document_Open() Call GenPrimaryValue End Sub Can someone someone please tell me what the hang up is? |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Is there a limit of words you can put in tables? | Tables | |||
Help - Random Work Order Number | Microsoft Word Help | |||
How do I insert chapter number with page number in footer? | Microsoft Word Help | |||
random number creation | Microsoft Word Help | |||
Maximum number of pages in a word document | Formatting Long Documents |