M
Mike
Hi! Here’s my problem:
I get over 1000 documents each day that I need to put into a newsletter.
Some of these documents have pictures, charts and graphs embedded.
When the Vertical alignment property for those pictures is set to Absolute,
then when I do mySelection.InsertFile() the pictures stay where they are and
do not move to the next page or down. That “side effect†caused me to spend
my Super Bowl weekend manually reformatting them.
I figured out that if I create a table in the exact location where the
picture is located, and place the picture in it, then this table can move
with the rest of the text. I have no problem creating a table. I can not to
position it where the picture used to be.
I created a file to illustrate my problem.
It can be downloaded at http://www.freefilehosting.net/?id=q939laXe
What am I doing wrong? Here’s my code:
Dim i As Integer
Dim sh As shape
Dim w As Single
Dim h As Single
Dim x As Single
Dim y As Single
For i = ActiveDocument.Shapes.Count To 1 Step -1
Dim tbl As Table
Dim rng As range
Dim frm As Frame
Dim ish As InlineShape
Set sh = ActiveDocument.Shapes(i)
sh.Anchor.Delete ‘ Does not seem to delete anything
w = sh.Width
h = sh.Height
x = sh.Left
y = sh.Top
'Set tbl = rng.ConvertToTable
'tbl.Columns.PreferredWidth = w
'tbl.Rows.SetHeight h, wdRowHeightExactly
If sh.Type = msoPicture Then
sh.Select
'Set tbl = Selection.range.ConvertToTable
Selection.Cut
Set tbl = Selection.Tables.Add(Selection.range, 1, 1,
wdWord9TableBehavior, WdAutoFitBehavior.wdAutoFitContent)
tbl.AllowPageBreaks = True
tbl.Columns.PreferredWidth = w
tbl.Rows.SetHeight h, wdRowHeightExactly
tbl.ApplyStyleHeadingRows = True
tbl.ApplyStyleLastRow = True
tbl.ApplyStyleFirstColumn = True
tbl.ApplyStyleLastColumn = True
tbl.Columns.Item(1).Cells.Item(1).range.Paste
End If
Next
Thank you in advance,
I get over 1000 documents each day that I need to put into a newsletter.
Some of these documents have pictures, charts and graphs embedded.
When the Vertical alignment property for those pictures is set to Absolute,
then when I do mySelection.InsertFile() the pictures stay where they are and
do not move to the next page or down. That “side effect†caused me to spend
my Super Bowl weekend manually reformatting them.
I figured out that if I create a table in the exact location where the
picture is located, and place the picture in it, then this table can move
with the rest of the text. I have no problem creating a table. I can not to
position it where the picture used to be.
I created a file to illustrate my problem.
It can be downloaded at http://www.freefilehosting.net/?id=q939laXe
What am I doing wrong? Here’s my code:
Dim i As Integer
Dim sh As shape
Dim w As Single
Dim h As Single
Dim x As Single
Dim y As Single
For i = ActiveDocument.Shapes.Count To 1 Step -1
Dim tbl As Table
Dim rng As range
Dim frm As Frame
Dim ish As InlineShape
Set sh = ActiveDocument.Shapes(i)
sh.Anchor.Delete ‘ Does not seem to delete anything
w = sh.Width
h = sh.Height
x = sh.Left
y = sh.Top
'Set tbl = rng.ConvertToTable
'tbl.Columns.PreferredWidth = w
'tbl.Rows.SetHeight h, wdRowHeightExactly
If sh.Type = msoPicture Then
sh.Select
'Set tbl = Selection.range.ConvertToTable
Selection.Cut
Set tbl = Selection.Tables.Add(Selection.range, 1, 1,
wdWord9TableBehavior, WdAutoFitBehavior.wdAutoFitContent)
tbl.AllowPageBreaks = True
tbl.Columns.PreferredWidth = w
tbl.Rows.SetHeight h, wdRowHeightExactly
tbl.ApplyStyleHeadingRows = True
tbl.ApplyStyleLastRow = True
tbl.ApplyStyleFirstColumn = True
tbl.ApplyStyleLastColumn = True
tbl.Columns.Item(1).Cells.Item(1).range.Paste
End If
Next
Thank you in advance,