ODMA Doc ID Field

J

Julie

Hi - I am using Word 03 with DocsOpen which is a document
management system. I have created a macro that puts the
document number in the footer of the document using the
ODMA Doc ID field found under Insert, Field,
DocProperties. The macro cleans up the Doc Id so it just
displays the doc number and version number:

Like this: 587298.1
Instead of : ODMA::blablabla/587298.1

Works great, except when I print, the ODMA junk comes
back. I do not have my fields updating when I print
(under tools, options).

I tried to recreate the macro so it cuts the number and
then does a paste special unformatted so it wouldn't be a
field anymore, but the macro code doesn't work.

Can anybody help?? Thanks!
 
P

Peter Jamieson

Suggestions:
a. lock the field, e.g. add

yourfieldobject.Locked = True

(could be Selection.Fields.Locked = True)
after you have modified the field result. You may need to unlock it before
modifying it. Or..
b. create your own Custom Document Property and put your derived value in
there, then use a { DOCPROPERTY myproperty } field to insert it. Or use a
document variable and a { DOCVARIABLE } field. Or..
c. post the existing macro code here and perhaps we can suggest a tweak.
 
J

Julie

Thanks Peter, I appreciate it. YES I want to lock the
field after it's been formatted. I put a new statement to
test it with the Filename field, my original statement for
the ODMA field is in as a comment for now. Can't quite
figure out where to put the locked statement.

Here's my code:


Sub StampInFooter()

'
' FileStamp Macro
' Macro recorded February 16, 2004 by
'
If Documents.Count = 0 Then Exit Sub


' Numinftr Macro
' Macro recorded 4/22/2004 by jstein
'
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or
ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader
ActiveWindow.ActivePane.View.SeekView =
wdSeekMainDocument

If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or
ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader
If Selection.HeaderFooter.IsHeader = True Then
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageFooter
Else
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader
End If


With ActiveDocument.PageSetup
.DifferentFirstPageHeaderFooter = False
End With
Selection.Fields.Add Range:=Selection.Range,
Type:=wdFieldEmpty, Text:= _
"FILENAME \* Caps \p ", PreserveFormatting:=True

'Selection.Fields.Add Range:=Selection.Range,
Type:=wdFieldEmpty, Text:= _
' "DOCPROPERTY ODMADocId ",
PreserveFormatting:=True

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "\"
.Replacement.Text = "."
.Forward = False
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
With Selection
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
End If
.Find.Execute Replace:=wdReplaceOne
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseEnd
Else
.Collapse Direction:=wdCollapseStart
End If
.Find.Execute
End With
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.Extend
Selection.Find.ClearFormatting
With Selection.Find
.Text = ":"
.Replacement.Text = "."
.Forward = False
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.TypeBackspace

Selection.EndKey Unit:=wdLine, Extend:=wdExtend
With Selection.Font
.Name = "Times New Roman"
.Size = 8
.Bold = False
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
.StrikeThrough = False
.DoubleStrikeThrough = False
.Outline = False
.Emboss = False
.Shadow = False
.Hidden = False
.SmallCaps = False
.AllCaps = False
.Color = wdColorAutomatic
.Engrave = False
.Superscript = False
.Subscript = False
.Spacing = 0
.Scaling = 100
.Position = 0
.Kerning = 0
.Animation = wdAnimationNone
End With

Selection.Fields.Locked = True

With ActiveDocument.PageSetup
.DifferentFirstPageHeaderFooter = True
End With
With Selection.Find
.Forward = True

End With


ActiveWindow.ActivePane.View.SeekView =
wdSeekMainDocument
End Sub
 
P

Peter Jamieson

OK, you have

Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"FILENAME \* Caps \p ", PreserveFormatting:=True

and after that, commented out, you have

'Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
' "DOCPROPERTY ODMADocId ", PreserveFormatting:=True

From what you have said, maybe the DOCPROPERTY field insertion should not be
commented out. Either way, try adding the following statement afterwards:

Selection.Fields.Locked = True
 

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