![]() |
#1
|
|||
|
|||
![]()
Hi to all,
I’d be glad if anyone could help me with some very slow cold. Given: Shape (in front of text) in the first cell of a table. Shape properties: Code:
With Shp .RelativeHorizontalPosition = wdRelativeHorizontalPositionColumn .RelativeVerticalPosition = wdRelativeVerticalPositionParagraph .Height = CentimetersToPoints(2.63) .Top = CentimetersToPoints(1.66) .Left = CentimetersToPoints(2.57) .Name = “ShapeToInsert” End With Problem: Whatever way I try as soon as the shape is pasted / duplicated, the properties .Left and .Top get lost. Which means, I need a second loop to adjust .Top and .Left again. Unfortunately the formatting takes about one second per shape. Do you have any idea how to improve the code or do you even see another approach than mine? Any help appreciated – as always NP |
#2
|
||||
|
||||
![]()
Assuming there is only one table in the document, you could use mail merge processes to speed things up.
With the image already placed in the first cell add the following to duplicate it to the rest of the table. Even with a large table it is pretty well instantaneous. Code:
Dim oDoc As Document Dim oFld As field Set oDoc = ActiveDocument With oDoc.MailMerge .MainDocumentType = wdMailingLabels WordBasic.MailMergePropagateLabel .MainDocumentType = wdNotAMergeDocument End With For Each oFld In ActiveDocument.Tables(1).Range.Fields If oFld.Type = wdFieldNext Then oFld.Delete Next oFld
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
![]()
Hi,
great idea - but ... I did not mention this in my OP because I didn't have a mail merge solution in my mind. There is aleady one InlineShape in each table cell. The inserted Shape should be on top of the InlineShape. As I'm not a mail merge expert, I really don't know if, and if yes, how to realize that challange. Sorry for not mentioning this earlier. NP |
#4
|
||||
|
||||
![]()
If it is the same inline shape in each cell of the table, the macro will duplicate everything in the first cell of the table to all the other cells. You don't have to know anything about mail merge, you just have to put the required images in the first cell.
The macro simply uses a function of mail merge to duplicate the cells. If they are different images in each cell, then the approach will not work.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#5
|
|||
|
|||
![]() Quote:
![]() It is the same inline shape in each cell of the table, so your code it works fine and fast. Thanks NP |
#6
|
|||
|
|||
![]() Quote:
Save formatted shape as autotext in normal.dot(m), insert autotext in each cell, delete autotext entry in normal.dot(m). Cheers NP |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
NobodysPerfect | Word VBA | 8 | 05-31-2014 03:51 AM |
Word 2000--Problem with format retention when pasting | JerryL | Word | 2 | 01-05-2014 07:20 PM |
Copy and pasting problem Word 2010 | Sarah262 | Word | 3 | 08-16-2012 03:46 PM |
![]() |
markg2 | Office | 1 | 08-04-2011 06:09 AM |
Pasting problem | Alec | Word | 1 | 11-09-2009 12:26 PM |