Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.word97vba,microsoft.public.word.tables,microsoft.public.word.vba
Fred Fred is offline
external usenet poster
 
Posts: 6
Default Select format of Table FormField dependent upon data entered

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   Report Post  
Posted to microsoft.public.word.word97vba,microsoft.public.word.tables
Jean-Guy Marcil Jean-Guy Marcil is offline
external usenet poster
 
Posts: 67
Default Select format of Table FormField dependent upon data entered

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   Report Post  
Posted to microsoft.public.word.tables
Fred Fred is offline
external usenet poster
 
Posts: 6
Default Select format of Table FormField dependent upon data entered

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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Data sources for different mailmerge letters Lee Mailmerge 11 January 27th 07 08:04 AM
Remove the leading zero from mergefield . Joergen Bondesen Mailmerge 15 December 9th 06 03:29 AM
formatting numeric data from Access merged into a Word table LacieMoon Mailmerge 11 December 5th 06 10:12 PM
want cells in a table to copy data from cells in another table Conrad D. Farner Tables 2 September 27th 06 04:21 PM
More Info On Directory Merge Please JohnB Mailmerge 14 September 6th 05 01:27 PM


All times are GMT +1. The time now is 05:10 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"