![]() |
#1
|
|||
|
|||
![]()
Hi All,
I am trying to simplify the process of entering custom document property values in word. My idea is to: • Set up at table at the beginning of the document where the user will enter in the custom document property values. See example below; Doc. Property....................Value Product Name .............Machine 500 Manufacturer ............Blogs Machines Ltd. • Use Marcos to take the data entered into a cell (Machine 500) and copy it, • Open the advanced properties menu and select the Product Name property, in the value text box paste (Machine 500), click modify and return to the document • Select all items, (Ctrl+A) and then update all fields (F9) All custom fields/document properties should now be updated to (Machine 500) I am new to Macros and VBA, I have made an attempt using Macros, but it doesn’t work. Is this even the right method? Is there a better way? Any help appreciated! |
#2
|
|||
|
|||
![]()
Where is your attempt?
Code:
Sub ScratchMacro() 'A basic Word macro coded by Greg Maxey Dim oTbl As Word.Table Dim oProp As DocumentProperty Dim lngIndex As Long Set oTbl = ActiveDocument.Tables(1) For lngIndex = 2 To oTbl.Rows.Count On Error GoTo Err_Property Set oProp = ActiveDocument.CustomDocumentProperties(fcnCellText(oTbl.Cell(lngIndex, 1))) oProp.Value = fcnCellText(oTbl.Cell(lngIndex, 2)) NextEntry: Next lngIndex ActiveDocument.Fields.Update lbl_Exit: Exit Sub Err_Property: ActiveDocument.CustomDocumentProperties.Add _ Name:=fcnCellText(oTbl.Cell(lngIndex, 1)), LinkToContent:=False, Value:=fcnCellText(oTbl.Cell(lngIndex, 2)), _ Type:=msoPropertyTypeString Resume NextEntry End Sub Function fcnCellText(oCell As Word.Cell) As String fcnCellText = Replace(oCell.Range.Text, Chr(13) + Chr(7), "") End Function |
#3
|
||||
|
||||
![]()
To add and update Custom Document Properties, see: http://support.microsoft.com/kb/212618/
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Add custom doc properties in "Doc properties control" | eazysnatch | Word | 2 | 09-13-2017 08:08 PM |
![]() |
jpb103 | Word VBA | 6 | 05-30-2014 07:08 AM |
Batch edit mail merge macros? | kbash | Word | 0 | 04-30-2014 08:32 AM |
Custom Properties | b-baker | Word | 1 | 03-01-2012 01:15 AM |
Looping though Custom Properties in VBA | suekay | Misc | 0 | 05-19-2006 06:10 AM |