Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-15-2014, 07:12 PM
thedr9wningman's Avatar
thedr9wningman thedr9wningman is offline Updating Document Properties without using advanced properties dialogue Windows 7 64bit Updating Document Properties without using advanced properties dialogue Office 2010 32bit
Novice
Updating Document Properties without using advanced properties dialogue
 
Join Date: Jan 2014
Location: Portland, OR
Posts: 3
thedr9wningman is on a distinguished road
Send a message via Yahoo to thedr9wningman Updating Document Properties without using advanced properties dialogue
Default Updating Document Properties without using advanced properties dialogue

Context
I'm trying to do some automation of a document and embed information into the template I'm developing.

Need:


I need to be able to have a quick and easy way for a user to choose a document property and assign it without having to go through advanced properties and modifying them. I'm amenable to a pop-up, a user-form, whatever it takes!

Ideally, I'd like a way for the user to choose a location/document property when they create a new document from this document template I'm creating. It really only needs to be chosen upon the creation of the document and likely won't be changed afterwards.

Current approach
I am using a custom document property called "Field_Office" to automate certain things, such as the field office location content control values (such as address, city, state, etc.), the banner image of the document (which includes address information and may allow for updated graphics in the future), etc.

I've gotten that part working, but assigning the Field_office property is not an intuitive thing, and I'm afraid users simply won't go through the steps necessary to reassign that particular property.

Alternatively, I've been trying to figure out a way to maybe link/assign the document property from a drop-down content control such as this XML:

Code:
<Field_office_Dropdown>
<location>Portland</location>
<location>Seattle</location>
<location>Los Angeles</location>
<location>Denver</location>
</Field_Office_Dropdown>
I suck at VB
My attempts at linking this easy user interface have failed and I'm not adept enough in Visual Basic to follow anything that is going on in all the forum channels I've read (and I've been reading for about 10 hours now...).

I've done research and training on VB and the most basic document properties and object properties I can't even seem to declare successfully. I do understand programming, but the complexities of Word's objects are a lot to take on all at once. That said, if I could just get past declaring the bloody variable, I would be on a better course of action!

I have tried following directions to a T, but I can't even figure out how to create a bookmark... and I considered myself pretty good at Word before encountering this issue!!

Might anyone be able to help? I included an example, stripped of my failed attempts at macros.
Attached Files
File Type: docx Example Word Template.docx (64.8 KB, 12 views)
Reply With Quote
  #2  
Old 01-16-2014, 04:03 PM
macropod's Avatar
macropod macropod is offline Updating Document Properties without using advanced properties dialogue Windows 7 32bit Updating Document Properties without using advanced properties dialogue Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,232
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Hi thedr9wningman,

For your address data and logos, you could probably get away with using just a single document property (e.g. the 'Office' property), coupled with INCLUDETEXT and, perhaps, INCLUDEPICTURE fields that reference the fuller details in external files. This would be much easier to code & maintain than putting it all into a macro. The INCLUDETEXT field would reference either a separate file for each location or a nominated bookmark within a common file shared by all locations. The code to update both the document property and the corresponding logo & address would then be as simple as;
Code:
Sub Demo()
With ActiveDocument
  .CustomDocumentProperties("Office").Text = InputBox("What is your Office location?", "Home Base")
  .Fields.Update
  .Fields.Unlink
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 01-20-2014, 05:26 PM
thedr9wningman's Avatar
thedr9wningman thedr9wningman is offline Updating Document Properties without using advanced properties dialogue Windows 7 64bit Updating Document Properties without using advanced properties dialogue Office 2010 32bit
Novice
Updating Document Properties without using advanced properties dialogue
 
Join Date: Jan 2014
Location: Portland, OR
Posts: 3
thedr9wningman is on a distinguished road
Send a message via Yahoo to thedr9wningman Updating Document Properties without using advanced properties dialogue
Default Runtime error 5

Hi Paul:

Thanks for your response. I'm not sure I totally understand it, but when I've tried running that code, I get a runtime error #5: Invalid procedure call on the line:
Code:
  .CustomDocumentProperties("Office").Text = InputBox("What is your Office location?", "Home Base")
Any idea why? Did I not define the document property of "Office" first? I'm totally grasping at straws because I don't know what sort of assumed document properties or variables are required here.

Thank you for your assistance.
Reply With Quote
  #4  
Old 01-20-2014, 05:56 PM
gmaxey gmaxey is offline Updating Document Properties without using advanced properties dialogue Windows 7 32bit Updating Document Properties without using advanced properties dialogue Office 2010 (Version 14.0)
Word MVP 2003-2009
 
Join Date: May 2010
Location: Marble, NC
Posts: 1,204
gmaxey has a spectacular aura aboutgmaxey has a spectacular aura aboutgmaxey has a spectacular aura about
Default

Yeah basically,

The properties listed as custom properties don't really exist until you use the name and assign a value:

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oCP As DocumentProperty
  With ActiveDocument
    On Error Resume Next
    Set oCP = .CustomDocumentProperties("Office")
    If Not Err.Number = 0 Then
      Set oCP = .CustomDocumentProperties.Add(Name:="Office", LinkToContent:=False, Value:=InputBox("What is your Office location?", "Home Base"), Type:=msoPropertyTypeString)
    Else
      oCP.Value = InputBox("What is your Office location?", "Home Base")
    End If
    On Error GoTo 0
    Debug.Print oCP.Value
  End With
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply

Tags
content controls, docproperty, document properties

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating Document Properties without using advanced properties dialogue Help with Document Properties Prompt Macro KJJ Word VBA 14 11-10-2016 08:18 PM
Updating Document Properties without using advanced properties dialogue Document properties driving sections in template cheffx1265 Word VBA 1 04-05-2013 05:25 AM
Key shortcut to access document properties eroock Word 0 12-11-2012 10:54 AM
document properties issues charris1980 Word 0 04-29-2009 12:49 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:00 AM.


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