Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.word.word97vba,microsoft.public.word.tables,microsoft.public.word.vba
|
|||
|
|||
![]()
Is it possible, using vb, to change the format of a Text form field in
a Table, dependent upon the data that has been entered ? I have the situation where a cell, indicating the status of a kick-off meeting, is to show any of the following values, TbD To be Decided whether required or not N/A Not Applicable/required to hold a meeting 100% Meeting held dd-mmm-yyyy scheduled date for the meeting I have it set at present to Regular Text, Unlimited. What I would like to be able to do is switch to Date (dd-mmm-yyyy) or Number (%) or leave it as text, based upon the data entered. Regards Fred |
#2
![]()
Posted to microsoft.public.word.word97vba,microsoft.public.word.tables
|
|||
|
|||
![]()
Fred was telling us:
Fred nous racontait que : Is it possible, using vb, to change the format of a Text form field in a Table, dependent upon the data that has been entered ? I have the situation where a cell, indicating the status of a kick-off meeting, is to show any of the following values, TbD To be Decided whether required or not N/A Not Applicable/required to hold a meeting 100% Meeting held dd-mmm-yyyy scheduled date for the meeting I have it set at present to Regular Text, Unlimited. What I would like to be able to do is switch to Date (dd-mmm-yyyy) or Number (%) or leave it as text, based upon the data entered. This can be a bit hairy and totally dependent on user good behaviour... First, since the format may change from entering to leaving the field, you may get a problem so that the user is not allow to leave the field if, for example, it was set to date but it is changed to "TbD"; in this case, "TbD" is not a valid date format and Word will not let the user leave the field. This is why I included a macro for Entry to reset the field format to regular text upon entry: OnEntry macro: '_______________________________________ Sub ResetFormat() Dim ffTarget As FormField Dim strFFResult As String Set ffTarget = Selection.Paragraphs(1).Range.FormFields(1) With ffTarget strFFResult = .Result .Result = "" With .TextInput .EditType Type:=wdRegularText, Format:="" End With .Result = strFFResult End With End Sub '_______________________________________ OnExit macro: '_______________________________________ Sub ChangeFormat() Dim ffTarget As FormField Dim strFFResult As String Set ffTarget = Selection.Paragraphs(1).Range.FormFields(1) With ffTarget strFFResult = .Result .Result = "" If IsNumeric(strFFResult) Then With .TextInput .EditType Type:=wdNumberText, Format:="0%" End With strFFResult = CStr(CLng(strFFResult) / 100) Else If IsNumeric(Replace(strFFResult, "-", "")) Then With .TextInput .EditType Type:=wdDateText, Format:="dd-MMM-yyyy" End With Else With .TextInput .EditType Type:=wdRegularText, Format:="" End With End If End If .Result = strFFResult End With End Sub '_______________________________________ -- Salut! _______________________________________ Jean-Guy Marcil - Word MVP ISTOO Word MVP site: http://www.word.mvps.org |
#3
![]()
Posted to microsoft.public.word.tables
|
|||
|
|||
![]()
Merci beaucoup Jean-Guy
One thing I omitted to mention is that I am using Word97 and VB has thrown a fit with the statement If IsNumeric(Replace(strFFResult, "-", "")) Then Is this a feature of Word2000 or an in-house routine you have ? Regards Fred |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Data sources for different mailmerge letters | Mailmerge | |||
Remove the leading zero from mergefield . | Mailmerge | |||
formatting numeric data from Access merged into a Word table | Mailmerge | |||
want cells in a table to copy data from cells in another table | Tables | |||
More Info On Directory Merge Please | Mailmerge |