Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-14-2012, 02:31 PM
Marrick13 Marrick13 is offline VBA to insert captions without appending to existing captions Windows XP VBA to insert captions without appending to existing captions Office 2010 32bit
Competent Performer
VBA to insert captions without appending to existing captions
 
Join Date: Jun 2006
Posts: 103
Marrick13 will become famous soon enough
Default VBA to insert captions without appending to existing captions

I’m attempting to create a utility that inserts captions for shapes, inline shapes and tables (separately). The code is the attached Sub InsertCaptionImages1 module does just that for inline shapes except for two things:



1. It can count the inline shapes in all stories but insert captions only for those in the main body
2. If the document already has captions for inlineshapes (or other objects that can have captions), it adds additional captions.

The idea of inserting captions separately for the three objects is that one might want to use different labels for each, such as “figure” for shapes and inline shapes; and “table” for tables; “equation” for something else; or a custom label as Word allows.

That any standard label can be applied to any object type, and that any caption label can be user-defined, leads me to believe the only option is to somehow tie the field code SEQ to the object type. (I’ve been using the attached “Sub ShowSelectionType” module to have Word tell me the type of object I’ve selected.)

I realize that captions and their text, if any, have no connection to the object for which they were created other than their initial placement, so I thought an approach for determining whether captions exist was to loop through the specific shape collection and detect whether each has a SEQ field, then ignore those that do and insert the caption for those that don’t. That might work in theory, but with my very limited VBA, I am not having any success in executing this idea, as evidenced by my stabs at it in Sub InsertCaptionImages2 (beginning about halfway down the module). I found some code that deletes captions and all of the text associated with them, which I tried to adapt for the unique insertion code, but didn’t succeed (that code is included in the attachment as “Sub DeleteCaptionNumText”).

There is also the fact that when you manually insert a caption for a shape, Word creates a small text box and writes the caption number and label in it. For inline shapes, the caption label and text are written in the body. I don’t know if this affects anything here, but I thought I’d mention it.

So is it possible to insert captions separately for shapes, inline shapes and tables without appending to existing captions? If not, I will just abandon the effort and make a note to run the Sub InsertCaptionImages1 only once….
Attached Files
File Type: doc Caption Test.doc (102.5 KB, 32 views)
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA to insert captions without appending to existing captions Move existing table captions bcarlier Word Tables 17 05-10-2014 02:36 PM
Captions/Styles NWoffice Word 5 10-06-2011 10:26 AM
VBA to insert captions without appending to existing captions creating tables for row of figures and captions gib65 Word 2 08-12-2011 01:25 PM
VBA to insert captions without appending to existing captions Captions (tables and figures) mcjohn Word 1 02-11-2010 10:36 PM
Captions dwilliams Word 0 10-07-2009 08:30 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:47 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