View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Unique value of Excel file

After serious thinking witek wrote :
I am looking for something which can serve as unique value for individual
Excel file.

It should be:
- unique for each individually created file (file - new)
- should not change if you make a copy of the file (save as) or modify the
file
- user should not be able to modify it (or at least it should be hard to
do).

any ideas?


You can store a value in a DefinedName, then hide the name so it
doesn't show up in lists. You do this by setting its .Visible property
to False.

ActiveWorkbook.Names.Add "UniqueName", "UniqueValue", False

To validate the workbook...

In some procedu
Dim sMsg$
If bNameExists("UniqueName") Then _
sMsg = "Validated" Else sMsg = "Not Validated"


A reusable function to check a workbook for an existing name:

Function bNameExists(sDefinedName$, Optional Wkb As Workbook) As
Boolean
Dim x As Object
If Wkb Is Nothing Then Set Wkb = ActiveWorkbook
On Error Resume Next
Set x = Wkb.Names(sDefinedName)
bNameExists = (Err = 0)
End Function

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion