![]() |
|
#2
|
||||
|
||||
|
You can't select an item in a closed document - even if that document is the template. You need to open the template in order to copy from it e.g. as follows. The code assumes the process you envisaged was otherwise correct.
Code:
Sub Macro1()
Dim oSource As Document
Dim oTarget As Document
Dim i As Long
Dim j As Long
If Documents.Count = 0 Then
MsgBox "No document open!"
GoTo lbl_Exit
End If
'Define the document to be processed
Set oTarget = ActiveDocument
'Open the source document
Set oSource = Documents.Open(ThisDocument.FullName)
'Find the shape that fits the criteria
For j = 1 To oSource.InlineShapes.Count
If oSource.InlineShapes(j).AlternativeText = " FIGURE_STYLE" Then
oSource.InlineShapes(j).Select
Selection.CopyFormat
Exit For
End If
Next
'Close the template
oSource.Close 0
'Find the shape to process
For i = 1 To oTarget.InlineShapes.Count
If oTarget.InlineShapes(i).Type = wdInlineShapePicture Then
oTarget.InlineShapes(i).Select
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.PasteFormat
End If
Next i
lbl_Exit:
Set oSource = Nothing
Set oTarget = Nothing
Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
1.image in a table 2.right click 3.menu click format 4.a format column appears
|
OldFatDog | Drawing and Graphics | 1 | 06-13-2014 11:19 PM |
| OneNote - Copy and paste image to the table | MartinK | OneNote | 0 | 09-03-2013 05:08 AM |
Copy text pastes image
|
kfranken8 | Word | 2 | 07-12-2012 09:33 PM |
Vector image format
|
jespestana | Drawing and Graphics | 4 | 11-26-2010 03:51 AM |
| Image Paste Format | curtisdehaven | Word | 0 | 09-16-2009 04:12 AM |