How to create random names or numbers for bookmark names

M

Marcel

Hi,

Does someone know of a kind of randomize function to create unique names for
bookmarks. If I merge or add documents to each other the bookmarks in these
documents must not be "overwritten" by bookmarks with the same name from the
document that is added.

Regards,

Marcel
 
P

Peter

You could use a GUID to name each bookmark. Naturally, you'll need some way to keep track of the bookmark names. Perhaps Document Variables would be suitable for that.

' creates a GUID, and passes it to the calling entity
Function getGUID() As String
Dim myTypeLib As Object
Dim strg As String
Set myTypeLib = CreateObject("Scriptlet.Typelib")
' Want to chop off the opening and closing brackets, as well as 2 non-printable characters at the end of the string.
strg = myTypeLib.GUID
getGUID = Mid(strg, 2, Len(strg) - 4)
Set myTypeLib = Nothing
End Function

hth,

-Peter
 
M

Marcel

Hi Peter,

I tested your code and it generates a nice global identifier. Very usefull
to me. I have to strip the dashes and every name should start with an letter
from A-Z. Yes, I'll have to manage the bookmark names but by using document
variables won't work. Doc variables are local to each document and
dissappear after insert. I'll find something to manage that.

Thanks,

Marcel

"Peter" <peterguy -at- hotmail -dot- com> schreef in bericht

You could use a GUID to name each bookmark. Naturally, you'll need some way
to keep track of the bookmark names. Perhaps Document Variables would be
suitable for that.

' creates a GUID, and passes it to the calling entity
Function getGUID() As String
Dim myTypeLib As Object
Dim strg As String
Set myTypeLib = CreateObject("Scriptlet.Typelib")
' Want to chop off the opening and closing brackets, as well as 2
non-printable characters at the end of the string.
strg = myTypeLib.GUID
getGUID = Mid(strg, 2, Len(strg) - 4)
Set myTypeLib = Nothing
End Function

hth,

-Peter
 

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