ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

Help me with MS Word styles

<< < (9/14) > >>

kfitting:
What I was trying to say is that your original code was looking inside range objects.  I dont know the Word Object model well enough to know if your fields are contained within the ranges you're looping through. 

The article I linked to gives a high level overview of the object model.  For example, in excel you have Workbooks, worksheets, ranges, and cells (among hundreds of other things). You can loop through all worksheets in a workbook, all cells in a worksheet, etc etc. 

For Word, I dont know where fields are "kept."  Sorry, I dont know the object model well enough, nor have the time tonight to look at it further.

superboyac:
What I was trying to say is that your original code was looking inside range objects.  I dont know the Word Object model well enough to know if your fields are contained within the ranges you're looping through. 

The article I linked to gives a high level overview of the object model.  For example, in excel you have Workbooks, worksheets, ranges, and cells (among hundreds of other things). You can loop through all worksheets in a workbook, all cells in a worksheet, etc etc. 

For Word, I dont know where fields are "kept."  Sorry, I dont know the object model well enough, nor have the time tonight to look at it further.

-kfitting (May 14, 2010, 05:43 PM)
--- End quote ---
Ok, I sort of get it.  I keep that in mind as a resource if i have to start messing around more with VB.  Eesh, I hope not.  I'll bet someone at work is pretty good with VB.

AndyM:
I'll bet someone at work is pretty good with VB.
-superboyac (May 14, 2010, 06:49 PM)
--- End quote ---

VBA Express, like DonationCoder for vba.  Someone will always answer your question and will often write some (or a lot) of code:

http://vbaexpress.com/forum/

AndyM:
For all the negative stuff we see and hear about all things MS, at the end of the day their office suite is incredibly capable and powerful if we only knew how to use it to it's fullest (I know I wish I did  :-[)     
-Target (May 13, 2010, 11:23 PM)
--- End quote ---
You know, this exact thought was probably the biggest lesson in all of this for me.  I have the tendency to bash the big time companies, not to mention my consistent railing against Word.  But now, I'm realizing that, yes, it is a powerful program.  It's me that has to learn how to use it.  And I don't know why that wasn't my attitude to begin with.  After all, software is a tool, it's up to you to learn to use it or even want to use it.  Anyway, this has all been very good for me.
-superboyac (May 14, 2010, 08:46 AM)
--- End quote ---

This was my story then, and I'm sticking with it  8):

https://www.donationcoder.com/forum/index.php?topic=5372.msg49315#msg49315

kfitting:
Here is a page that shows why this can be different for different people.  Update Fields VBA

Going back to the article on the way Word thinks, each compartment is a container for different things.  Fields could possibly go in many of the different compartments, depending on how (and where) you inserted the field.  In the code SuperBoyAC first posted, you loop through all Word ranges, look in each range's Fields collection, and then cycle through those fields. 

In the first reply of the webpage I just linked to, the user loops through each field in the Document's Fields collection... which is different than what the first code does.

It's all about object hierarchies, and I agree can be very very confusing.  However, dont go bashing VB for this problem!  ;)  This is a "problem" with any object-oriented language/application.  You can bash MS for making the Word Object Model so complex, but VB/VBA is not at fault here.  If you try to script Word through any com enabled language you will have to use the same types of object references.

Without your document in front of me I dont know which container the fields you are trying to update are in.  That's where the Object Model map can come in handy (I dont think the one I linked to above is the full map):  it shows you the object hierarchies and where each piece can be located.

Hope that helps explain... I doubt it solves the problem.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version