Senad Isanovic was telling us:
Senad Isanovic nous racontait que :
Many Thanks for a very good answer.
No it does not have to in the footer, I can add it at the bottom of
the first page or in the left margin of the first page. The only
thing that is important is that it is somewhere on the first page and
that the user can not easily delete this unique document number. That
was the original reason to why I 'm adding a textbox in the footer. I
Then it is probably best to use the footer to avoid accidental deletion.
tried also to add a little table with only one cell on the first page
and then to read/write the unique number to that cell in my table but
the document can contain one or several other tables too and I don't
know how to refer to my little table.
Can I name the table to something unique instead of using the table
index number?
ActiveDocument.Tables(1).Rows(1).Cells(1).Range.Text = "INT98878-v1"
No, you cannot name tables, but, you can assign a bookmark to a table, as in
this sample code that assumes that you have already made sure that section
1 in the document has a different first page footer:
'_______________________________________
Dim tblID As Table
Dim rgeFooter As Range
Const strTableName As String = "Table_ID"
'Set the range in the footer that already has a diffrent first page footer
Set rgeFooter = ActiveDocument.Sections(1).Footers(wdHeaderFooterFirstPage)
_
.Range.Paragraphs(1).Range
rgeFooter.Collapse wdCollapseStart
'Add a table in that footer and assign bookmark
Set tblID = rgeFooter.Tables.Add(rgeFooter, 1, 1)
'set width
tblID.Columns(1).Width = InchesToPoints(1.25)
ActiveDocument.Bookmarks.Add strTableName, tblID.Range
'To use the table in the bookmark
With ActiveDocument.Bookmarks(strTableName).Range.Tables(1)
.Cell(1, 1).Range.Text = "INT98878-v1"
End With
'_______________________________________
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site:
http://www.word.mvps.org