Tuesday, 17 April 2012

Word 2010 Auto Insert Text VBA

UpdateAll() from http://www.gmayor.com/installing_macro.htm



Option Explicit

Sub ToggleHyperlinkCtrlClick()
SetFormText

UpdateAll

End Sub


Sub UpdateAll()
Dim oStory As Range
For Each oStory In ActiveDocument.StoryRanges
oStory.Fields.Update
If oStory.StoryType <> wdMainTextStory Then
While Not (oStory.NextStoryRange Is Nothing)
Set oStory = oStory.NextStoryRange
oStory.Fields.Update
Wend
End If
Next oStory
Set oStory = Nothing
End Sub



Sub SetFormText()
Dim theString As String
theString = InputBox("Type Text Please", "")
ActiveDocument.FormFields(1).TextInput.Default = theString
End Sub





To get {REF Text1}, type REF Text1, highlight and type cntrl+F9

No comments:

Post a Comment