Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-31-2013, 09:13 AM
SaneMan SaneMan is offline VBA to insert field references Windows 7 64bit VBA to insert field references Office 2007
Novice
VBA to insert field references
 
Join Date: Jan 2011
Posts: 20
SaneMan is on a distinguished road
Default VBA to insert field references

Hi all



I'd be grateful if someone could help me with a Word VBA query I have. I'm trying to write a code which automatically insert field references into a word document.

You can do this manually by pressing Ctrl & F9 and then type the reference into the field. However, when I record myself doing this the macro only picks it up as plain text, not as a reference.

Does anyone know how I would go about doing this via VBA, or if it's even possible.

Many thanks

Antony
Reply With Quote
  #2  
Old 10-31-2013, 02:32 PM
macropod's Avatar
macropod macropod is offline VBA to insert field references Windows 7 32bit VBA to insert field references Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,374
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Antony,

Here's a simple demo of inserting a QUOTE field at the selection:
Code:
Sub Demo()
With Selection
  .Fields.Add Range:=.Range, Type:=wdFieldEmpty, _
    PreserveFormatting:=False, Text:="QUOTE" & Chr(34) & "Text to display" & Chr(34)
  .Fields.Update
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 11-01-2013, 02:38 AM
SaneMan SaneMan is offline VBA to insert field references Windows 7 64bit VBA to insert field references Office 2007
Novice
VBA to insert field references
 
Join Date: Jan 2011
Posts: 20
SaneMan is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Hi Antony,

Here's a simple demo of inserting a QUOTE field at the selection:
Code:
Sub Demo()
With Selection
  .Fields.Add Range:=.Range, Type:=wdFieldEmpty, _
    PreserveFormatting:=False, Text:="QUOTE" & Chr(34) & "Text to display" & Chr(34)
  .Fields.Update
End With
End Sub
Worked perfectly. Thanks a bunch!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA to insert field references How to make a SEQ field show up in cross references? Roscoe Word 5 06-01-2016 01:39 PM
VBA to insert field references Template field to insert picture from default location LittleCrunch Word 1 10-28-2013 03:50 AM
MACRO - Insert row based on Form Field Criteria Elan05 Word VBA 5 04-16-2013 06:39 AM
Formula to subtract one month from due date field in reminder field ghumdinger Outlook 1 10-01-2011 12:09 AM
VBA to insert field references Insert "must complete" text field Markw Word 5 11-19-2009 08:29 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:20 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft