Solved

how do i add a caption to a floating shape not inline with MS Word VBA

Posted on 2013-01-28
4
387 Views
Last Modified: 2013-01-29
how do i add a caption to a floating shape not inline with MS Word VBA
0
Comment
Question by:Dov_B
  • 2
4 Comments
 
LVL 6

Expert Comment

by:nickinthooz
ID: 38829414
In your document, drag to draw the text box over the object.
    On the Drawing Tools Format tab, in the Shape Styles group, click Shape Fill, and then click No Fill.
    In the Arrange group, click Text Wrapping, and then click the text wrapping option that you used for the object.
    Under Text Box Tools, on the Format tab, in the Arrange group, click Send Behind Text.
    Right-click the text box, and then click Format Shape.
    Click Text Box, and then set the internal margin values to 0.
    Select the object, and then click Cut in the Clipboard group on the Home tab. Or press CTRL+X.
    Click in the text box, and then click Paste in the Clipboard group on the Home tab. Or press CTRL+V.
    Select the object, and insert the caption.

taken from here:
http://office.microsoft.com/en-us/word-help/add-captions-in-word-HA102227021.aspx
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 38829491
This inserts a caption for the first shape in a document.
    ActiveDocument.Shapes(1).Select
    Selection.InsertCaption "Figure", , , wdCaptionPositionBelow

Open in new window

0
 

Author Comment

by:Dov_B
ID: 38829672
Thanks GrahamSkan can you help me with a few issues:
1) it makes a very large caption box Ineed just a teeny one for a number
2.how do iset the font
3) how do I make it see through
0
 
LVL 76

Assisted Solution

by:GrahamSkan
GrahamSkan earned 500 total points
ID: 38830455
The box is the same width as the shape that it is labelling. You can access the box and its properties so:
Sub AddSmallTransparentCaption()
    Dim sh As Shape
    Dim tb As Shape
    Dim s As Integer

    s = 1
    
    Set sh = ActiveDocument.Shapes(s)
    sh.Select
    Selection.InsertCaption "Figure", , , wdCaptionPositionBelow
    
    Set tb = ActiveDocument.Shapes(s + 1)
    With tb
        .TextFrame.TextRange.Font.Size = 6
        .Fill.Transparency = 1
        .TextFrame.AutoSize = True 'doesn't seem to work
    End With
End Sub

Open in new window

You will see that I have commented that Autosize doesn't work. If it doesn't work on your system either, you will have to have to use the properties of the textbox to change it, e.g.
    tb.Width = 30
    tb.Height = 10

Open in new window

I don't know of a simple way to calculate the size, so trial and error would be needed.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question