How to replace text in word document with random series number

Hi Community,

I have an query which i have an sequence in word which i need to replace with random number just for reference.

Example : 000/1234/September

the place 1234 need to write random number sequence after every run.

can you please suggest any procedure for this .

Hi @chaitanyaKumar

Input = "000/1234/September"
randomNumber = New Random().Next(1000, 9999).ToString()
Output = Input.Replace("1234", randomNumber)

Regards,

Hi Irtetala,

as this process runs multiple times so even the number will be printing different right

Ex : 1st Run 0001
2nd Run 0002 like it will print ??

@chaitanyaKumar

Yes, it will print random numbers beteeen 1000 and 9999

Regards,

can we make it like sequence kind like 0001,0002,0003 kind too ?

@chaitanyaKumar

If you want numbers between 0001 to 9999 then change like below

New Random().Next(0001, 9999).ToString()
1 Like

okay thanks for the solution it works…

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.