Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 11-21-2014, 11:53 AM
gmaxey gmaxey is offline Edit Custom Doc Properties using Macros Windows 7 32bit Edit Custom Doc Properties using Macros Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

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
I wouldn't use that method. I would create a Product Name and Manufacture content control, map them to a customXMLnode and then copy and paste the controls where I need the same data repeated.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Add custom doc properties in "Doc properties control" eazysnatch Word 2 09-13-2017 08:08 PM
Edit Custom Doc Properties using Macros Searching with Custom Properties 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

Other Forums: Access Forums

All times are GMT -7. The time now is 05:21 AM.


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