Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-21-2014, 07:28 AM
pmcen08 pmcen08 is offline Edit Custom Doc Properties using Macros Windows 7 64bit Edit Custom Doc Properties using Macros Office 2010 64bit
Novice
Edit Custom Doc Properties using Macros
 
Join Date: Nov 2014
Posts: 1
pmcen08 is on a distinguished road
Default Edit Custom Doc Properties using Macros

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!
Reply With Quote
  #2  
Old 11-21-2014, 11:53 AM
gmaxey gmaxey is online now 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,422
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
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
  #3  
Old 11-21-2014, 02:12 PM
macropod's Avatar
macropod macropod is offline Edit Custom Doc Properties using Macros Windows 7 64bit Edit Custom Doc Properties using Macros Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

To add and update Custom Document Properties, see: http://support.microsoft.com/kb/212618/
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


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 12:36 PM.


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