View Single Post
 
Old 08-19-2015, 01:29 AM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,143
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

With protected forms ruled out, you cannot do it automatically without macros, so you would need to save the document as either a macro enabled document or template and the users would have to allow the macro to run.

For Word 2013 or 2010 (Word 2007 will require additional code, and it will not work in earlier versions which do not support content controls)

Insert a plain text content control at each location, name the first SQFT and the second SQM. Set the default texts of each to 0 and check the property to disable deletion. In the second field only check the 'Contents cannot be edited check box' property

In the ThisDocument module of the document/template add the following code which will calculate to two decimal places the value of sq ft in sq m.

Code:
Option Explicit

Private Sub Document_ContentControlOnExit(ByVal CC As ContentControl, Cancel As Boolean)
Dim oCC As ContentControl
    Select Case CC.Title
        Case "SQFT"
            'Validate/format data entered in variable content control.
            If Not IsNumeric(CC.Range.Text) Then
                Cancel = True
                Beep
                CC.Range.Text = "0"
                With ActiveDocument.SelectContentControlsByTitle("SQM").Item(1)
                    .LockContents = False
                    .Range.Text = "0.00"
                    .LockContents = True
                End With
                CC.Range.Select
                Exit Sub
            Else
                CC.Range.Text = Format(Val(CC.Range.Text))
            End If
            'Update content control contents.
            Set oCC = ActiveDocument.SelectContentControlsByTitle("SQM").Item(1)
            With oCC
                .LockContents = False
                .Range.Text = Format(Val(ActiveDocument.SelectContentControlsByTitle("SQFT").Item(1).Range.Text * 0.09290304), "0.00")
                .LockContents = True
            End With
    End Select
    Set oCC = Nothing
lbl_Exit:
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote