Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-10-2013, 09:01 AM
nschroeder nschroeder is offline Need VBA Function in Word table formula Windows 7 64bit Need VBA Function in Word table formula Office 2010 64bit
Novice
Need VBA Function in Word table formula
 
Join Date: May 2013
Posts: 3
nschroeder is on a distinguished road
Default Need VBA Function in Word table formula

We have loan approval Word documents that contain numerous tables of customer information, often redundant. We want to be able to enter common borrower data in one place and have it replicated where needed, and this applies to potentially multiple secondary borrowers in the same document. We tried using Insert - Quick Parts - Document Property, which works fine but is limited to 15 values, and we need more. I'm trying to create VBA functions and pull the values into table formulas, but I'm getting a syntax error. For example, in the document code, I have:
Code:
Function Bor1Name()
    Bor1Name = "Joe Deadbeat"
End Function
In the table, if I put a formula: =Bor1Name, I get "!Undefined Bookmark, BOR1NAME". If I put =Bor1Name() I get "!Syntax Error, ("



Any suggestions on how to get the formula/function to work? Or is there a better way to accomplish what we need? Links to data in an Excel document won't work for this app, since the data is coming from a web site.
Reply With Quote
  #2  
Old 05-10-2013, 02:47 PM
fumei fumei is offline Need VBA Function in Word table formula Windows 7 64bit Need VBA Function in Word table formula Office XP
Expert
 
Join Date: Jan 2013
Posts: 440
fumei is on a distinguished road
Default

Quote:
We want to be able to enter common borrower data in one place and have it replicated where needed,
Try using a REF field.
Reply With Quote
  #3  
Old 05-10-2013, 04:00 PM
macropod's Avatar
macropod macropod is offline Need VBA Function in Word table formula Windows 7 64bit Need VBA Function in Word table formula Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

If you modify your code to populate custom document properties (one set for the primary borrower and one set each for the maximum # of secondary borrowers) with one instance each of your variables, you can use however many DOCPROPERTY fields in the document you need to replicate the info wherever you a given variable to appear. Supplemented with IF field coding, the document content can likewise be varied, all via a simple .Fields.Update directive.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 05-13-2013, 09:14 AM
nschroeder nschroeder is offline Need VBA Function in Word table formula Windows 7 64bit Need VBA Function in Word table formula Office 2010 64bit
Novice
Need VBA Function in Word table formula
 
Join Date: May 2013
Posts: 3
nschroeder is on a distinguished road
Default

I like where you're going, but I'm not sure how to get there. I'm an Excel/Access/VBA guy, but haven't done much in Word/VBA. I figured out how to create a custom Bor1Name property, but it doesn't show up in Quick Parts - Document Properties, so that would imply that the only way to access custom properties is through code. Could you please give more specifics about how to create and update custom properties through code, and then how to use them to populate table fields? I tried to record creating the property, but the macro came up blank.

Thanks for your help.
Reply With Quote
  #5  
Old 05-13-2013, 02:16 PM
gmaxey gmaxey is offline Need VBA Function in Word table formula Windows 7 32bit Need VBA Function in Word table formula Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,428
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

Why don't you use mapped content controls?

http://gregmaxey.com/word_tip_pages/...ols_addin.html
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #6  
Old 05-13-2013, 02:41 PM
nschroeder nschroeder is offline Need VBA Function in Word table formula Windows 7 64bit Need VBA Function in Word table formula Office 2010 32bit
Novice
Need VBA Function in Word table formula
 
Join Date: May 2013
Posts: 3
nschroeder is on a distinguished road
Default

Thank you all for your suggestions. It appears there are a lot of options. We'll play around and figure out what will work best for us.

Thanks again!
Reply With Quote
  #7  
Old 05-13-2013, 03:58 PM
macropod's Avatar
macropod macropod is offline Need VBA Function in Word table formula Windows 7 64bit Need VBA Function in Word table formula Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

Quote:
Originally Posted by nschroeder View Post
I like where you're going, but I'm not sure how to get there. I'm an Excel/Access/VBA guy, but haven't done much in Word/VBA. I figured out how to create a custom Bor1Name property, but it doesn't show up in Quick Parts - Document Properties, so that would imply that the only way to access custom properties is through code. Could you please give more specifics about how to create and update custom properties through code, and then how to use them to populate table fields? I tried to record creating the property, but the macro came up blank.

Thanks for your help.
having created your custom Bor1Name property, you can reference it anywhere in the document via a DOCPROPERTY field, which you can create via Ctrl-F9, then typing 'DOCPROPERY Bor1Name' between the field braces, thus: {DOCPROPERTY Bor1Name}, then pressing F9 to update. Adding fields through code isn't particularly difficult either.

For some code examples using custom document properties, see:
https://www.msofficeforums.com/word-...numbering.html
https://www.msofficeforums.com/word-...ent+propert%2A
https://www.msofficeforums.com/word/...ferencing.html
A thread that discusses both mapped content controls and the use of custom document properties is:
https://www.msofficeforums.com/word-...t-control.html
Although the above examples don't involve other applications (eg Access/Excel), the code for the Word side of things would be much the same - automating Word from those other apps isn't especially complicated.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
function table formula



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need VBA Function in Word table formula Data table search function omtinole Excel Programming 1 07-13-2012 10:03 PM
Formula help in word table mygsdsni Word Tables 3 01-04-2012 02:36 PM
Need VBA Function in Word table formula Would appreciate help with formula or function e_a_g_l_e_p_i Excel 1 03-12-2011 08:53 PM
Need VBA Function in Word table formula Formula and Table Help! steveman1234 Word Tables 2 03-28-2010 06:20 PM
Help with Word table formula fritman99 Word Tables 1 09-02-2009 05:36 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:23 AM.


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