Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2006

Tip: Looking for answers? Try searching our database.

How to generate _Ref autonumber?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
no.email@hotmail.com - 26 Apr 2006 12:50 GMT
Hi,

I'm adding references to a document and would like to generate (to keep it
consistent with what word creates) the _Ref autonumber.

Does anybody know if it's accessible through any functions etc.?

Thanks,

R.
Jezebel - 26 Apr 2006 13:04 GMT
Those are just random numbers. You can create your own using RND()

> Hi,
>
[quoted text clipped - 6 lines]
>
> R.
Dave Lett - 26 Apr 2006 13:52 GMT
Hi,

Rnd will raise an error by itself because it returns values between zero and
one. You can use something like the following to test for the existence of a
bookmark and then add one, using a random number:

Dim iRandom As Integer
iRandom = Int((10000 - 1 + 1) * Rnd + 1)
Do While ActiveDocument.Bookmarks.Exists("_Ref" & iRandom)
   iRandom = Int((10000 - 1 + 1) * Rnd + 1)
Loop
ActiveDocument.Bookmarks.Add Name:="_Ref" & iRandom

HTH,
Dave

> Those are just random numbers. You can create your own using RND()
>
[quoted text clipped - 8 lines]
>>
>> R.
Jean-Guy Marcil - 26 Apr 2006 14:46 GMT
Dave Lett was telling us:
Dave Lett nous racontait que :

> Hi,
>
[quoted text clipped - 8 lines]
> Loop
> ActiveDocument.Bookmarks.Add Name:="_Ref" & iRandom

Sorry to be picky, but..
Why
    iRandom = Int((10000 - 1 + 1) * Rnd + 1)
???
Souldn't it be:
   iRandom = Int((10000 * Rnd) + 1)
???

I mean
   10000 - 1 + 1 always equals 10000
No?

And, could we use:
   iRandom = Int(10000 * Rnd)
It seems to give the same result.

I am not very good with Maths...this is why I am asking!

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

Dave Lett - 26 Apr 2006 14:57 GMT
Not picky, just an excellent eye.
I used the example in the MS Help file topic Rnd Function. In that topic,
the example is

Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
Here, upperbound is the highest number in the range, and lowerbound is the
lowest number in the range.

Instead of passing values for upperbound and lowerbound, I simply changed
the values and didn't take the time to review the line for, well,
intelligence.

Dave

> Dave Lett was telling us:
> Dave Lett nous racontait que :
[quoted text clipped - 29 lines]
>
> I am not very good with Maths...this is why I am asking!
Jean-Guy Marcil - 26 Apr 2006 15:28 GMT
Dave Lett was telling us:
Dave Lett nous racontait que :

> Not picky, just an excellent eye.
> I used the example in the MS Help file topic Rnd Function. In that
[quoted text clipped - 7 lines]
> changed the values and didn't take the time to review the line for,
> well, intelligence.

LOL
Don't worry, it happens to all of us!

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.