Prev: Subdocuments is always collapsed when opening the masterdoc
Next: reconciling two documents in Word
From: Catherine on 26 Jan 2010 09:51 When i add a new custom field E.g {DOCPROPERTY "Transaction Comments" }to my document (Type: Text) there is a restriction to 255 characters. Is there any way to increase this? Or is this a M/S word restriction that cannot be changed?
From: Jay Freedman on 26 Jan 2010 11:18 Catherine wrote: > When i add a new custom field E.g {DOCPROPERTY "Transaction > Comments" }to my document (Type: Text) there is a restriction to 255 > characters. > Is there any way to increase this? Or is this a M/S word restriction > that cannot be changed? It is a restriction that can't be changed. I didn't find any official documentation of this, but the result of the following macro makes it clear that Word truncates the input to 255 characters: Sub x() Dim mystr As String Dim myCP As DocumentProperty mystr = String(260, "A") ActiveDocument.CustomDocumentProperties.Add _ Name:="test1", LinkToContent:=False, _ Type:=msoPropertyTypeString, _ Value:=mystr MsgBox Len(ActiveDocument.CustomDocumentProperties("test1").Value) End Sub However, there is no such restriction on document *variables*, as the result of this similar macro shows: Sub y() Dim mystr As String Dim myVar As Variable mystr = String(500, "A") ActiveDocument.Variables.Add _ Name:="test1", Value:=mystr MsgBox Len(ActiveDocument.Variables("test1").Value) End Sub In the document, you can display the value of the variable with a field {DOCVARIABLE test1}. The two main differences between custom document properties and document variables are (a) all document variables are strings, and (b) there is no dialog for setting document variables, so they must be set through a macro -- this may be a drawback or a benefit, depending on whether you want to allow users to change the value. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
From: Catherine on 26 Jan 2010 12:36 Jay, Many thanks for your prompt help. Catherine "Jay Freedman" wrote: > Catherine wrote: > > When i add a new custom field E.g {DOCPROPERTY "Transaction > > Comments" }to my document (Type: Text) there is a restriction to 255 > > characters. > > Is there any way to increase this? Or is this a M/S word restriction > > that cannot be changed? > > It is a restriction that can't be changed. I didn't find any official > documentation of this, but the result of the following macro makes it clear > that Word truncates the input to 255 characters: > > Sub x() > Dim mystr As String > Dim myCP As DocumentProperty > mystr = String(260, "A") > ActiveDocument.CustomDocumentProperties.Add _ > Name:="test1", LinkToContent:=False, _ > Type:=msoPropertyTypeString, _ > Value:=mystr > > MsgBox Len(ActiveDocument.CustomDocumentProperties("test1").Value) > End Sub > > However, there is no such restriction on document *variables*, as the result > of this similar macro shows: > > Sub y() > Dim mystr As String > Dim myVar As Variable > mystr = String(500, "A") > ActiveDocument.Variables.Add _ > Name:="test1", Value:=mystr > > MsgBox Len(ActiveDocument.Variables("test1").Value) > End Sub > > In the document, you can display the value of the variable with a field > {DOCVARIABLE test1}. > > The two main differences between custom document properties and document > variables are (a) all document variables are strings, and (b) there is no > dialog for setting document variables, so they must be set through a > macro -- this may be a drawback or a benefit, depending on whether you want > to allow users to change the value. > > -- > Regards, > Jay Freedman > Microsoft Word MVP FAQ: http://word.mvps.org > Email cannot be acknowledged; please post all follow-ups to the newsgroup so > all may benefit. > > > . >
|
Pages: 1 Prev: Subdocuments is always collapsed when opening the masterdoc Next: reconciling two documents in Word |