View Single Post
 
Old 02-01-2014, 07:10 PM
Hdata Hdata is offline Windows 7 32bit Office 2010 32bit
Novice
 
Join Date: Jan 2014
Posts: 26
Hdata is on a distinguished road
Thumbs up Add text to DocProperty with VBA?

In the past, I have added selected text to bookmarks programmatically with VBA as indicated in Sub Macro11(). Works great.

My first try with Custom Document Properties!

I would like to add selected text from a word document to DocProperty Programmatically with VBA. Not sure if this is possible, maybe my syntax needs work? Any Help.


Code:
 
Sub Macro11()
    With ActiveDocument.Bookmarks
        .Add Range:=Selection.Range, Name:="test1bm"
        .DefaultSorting = wdSortByName
        .ShowHidden = False
    End With
End Sub
,

Code:
 
Sub Macro13()
    With ActiveDocument
        .Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
        "DOCPROPERTY  FirstTest1Custom ", PreserveFormatting:=True
    End With
End Sub
Reply With Quote