![]() |
#1
|
|||
|
|||
![]()
Hi all, text in caps below indicates my problem. Thanks in advance...
Sub InsertPhotoRefInsideCallout() ' ' Inserts photo label and number reference into callout 'Paste new autotext callout Selection.TypeText "x" Selection.Range.InsertAutoText 'WANTING FOLLOWING LINE TO MOVE CURSOR INSIDE CALLOUT SO PHOTO REFERENCE BELOW CAN BE PASTED ActiveDocument.Shapes.Range(Array("Rounded Rectangular Callout 38")).Select 'Paste "Photo 1" reference in callout Selection.InsertCrossReference ReferenceType:="Photo", ReferenceKind:= _ wdOnlyLabelAndNumber, ReferenceItem:="1", InsertAsHyperlink:=False, _ IncludePosition:=False, SeparateNumbers:=False, SeparatorString:=" " End Sub |
#2
|
||||
|
||||
![]()
I think your logic is a little flawed because you aren't being explicit enough to determine which shape you want to address. It appears that it might work if you only ever use it once in a document but you will have several problems if you expect to use it a second time.
Presumably you got that shape name from the shape you saved it into the building blocks, what happens if you have inserted the building block more than once into the document, which instance should this cross-ref go into? How should the callout be positioned if there is no position info about the photo caption which I assume is already on the page somewhere? Typically, cross-references point at a caption and it is the caption that might be positioned in a text box sitting under the photo. The cross-reference normally sits somewhere in the text rather than in a shape on the page. To get you started, have a look at this code. If you run it on a document containing a couple of your shapes you will see that you might have more than one shape with the same name but they will have a unique ID. You can also see that you can place text (or a cross-ref) inside a shape by using its TextFrame.TextRange. Code:
Sub ShowMe() Dim aShp As Shape For Each aShp In ActiveDocument.Shapes Debug.Print aShp.Name, aShp.ID Next aShp With ActiveDocument.Shapes(1) .TextFrame.TextRange.Text = "Hi Mum" End With End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Cross-reference with full context a numbered list inside another multilevel list (list style) | MatLcq | Word | 0 | 02-01-2021 06:00 AM |
![]() |
TheSkiBoy | PowerPoint | 3 | 12-08-2014 12:33 PM |
Insert a TOC inside a table cell | simobk | Word | 3 | 10-28-2013 01:18 PM |
![]() |
wabash12 | PowerPoint | 2 | 06-14-2013 06:32 AM |
![]() |
Jrmatm26538 | PowerPoint | 6 | 02-14-2012 09:00 AM |