Microsoft Office Forums Set REF field value (result) within VBA

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-30-2019, 05:33 PM
eduzs eduzs is offline Set REF field value (result) within VBA Windows 10 Set REF field value (result) within VBA Office 2010 32bit
Competent Performer
Set REF field value (result) within VBA
 
Join Date: May 2017
Posts: 174
eduzs is on a distinguished road
Default Set REF field value (result) within VBA

I have some field in a document, like:


{ MyName }
How to set MyName value with vba?
When I was using { DOCVARIABLE MyName } I did that so simple with activedocument.variables("MyName")="Hello".

Thanks
Reply With Quote
  #2  
Old 05-30-2019, 06:15 PM
Guessed's Avatar
Guessed Guessed is offline Set REF field value (result) within VBA Windows 10 Set REF field value (result) within VBA Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 1,374
Guessed is a jewel in the roughGuessed is a jewel in the roughGuessed is a jewel in the roughGuessed is a jewel in the rough
Default

If that field is working then you must have a bookmark in the document of the same name
Code:
Sub ResetBookmark()
  Dim sBkmk As String, aRng As Range
  sBkmk = "MyName"
  If ActiveDocument.Bookmarks.Exists(sBkmk) Then
    Set aRng = ActiveDocument.Bookmarks(sBkmk).Range
    aRng.Text = "Hello from the other side"
    ActiveDocument.Bookmarks.Add Name:=sBkmk, Range:=aRng
  End If
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 05-31-2019, 02:33 AM
eduzs eduzs is offline Set REF field value (result) within VBA Windows 10 Set REF field value (result) within VBA Office 2010 32bit
Competent Performer
Set REF field value (result) within VBA
 
Join Date: May 2017
Posts: 174
eduzs is on a distinguished road
Default

Thank you! I'm going to stick with DOCVARIABLE as it's a bit simpler to manage within VBA.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Set REF field value (result) within VBA Field not show result eduzs Word 9 06-02-2019 03:48 PM
Set REF field value (result) within VBA One Cell that controlls spread sheet result button to change simple fomula result RAH Excel Programming 5 03-31-2018 04:52 PM
Set REF field value (result) within VBA Result Calculator Raza Excel Programming 7 01-26-2015 11:35 PM
result of merge field is incorrect VHV Mail Merge 3 06-16-2014 03:46 PM
Set REF field value (result) within VBA Form field calculation returning 2x correct result Jschueller Word 1 08-20-2013 01:51 PM


All times are GMT -7. The time now is 01:17 PM.


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