C
Chris Joyce
I've almost got this one working ( even if its not neat ) but I can't seem
to work out one small problam .
The aim is to locate all InlineShapes, split the table cell they are in and
move them to the new cell .
I've got it working but it seems to act on the forst image twice ! ,
if I select anything after the first image then run the macro everything is
ok !
I can't seem to work out why ?
maybe there is a better way to do the same action.
Chris
Sub SplitCellsWithImg()
' Find All InlineImages and split the cell
' then move the Inline to the new cell
Dim oILS As InlineShape
Dim oRg As Range
For Each oILS In ActiveDocument.InlineShapes
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^g"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Cells.Split NumRows:=1, NumColumns:=2,
MergeBeforeSplit:=False
Selection.MoveLeft unit:=wdCharacter, Count:=1
Selection.MoveRight unit:=wdCharacter, Count:=11
Selection.MoveLeft unit:=wdCharacter, Count:=1
Selection.MoveRight unit:=wdCharacter, Count:=1
Selection.MoveLeft unit:=wdCharacter, Count:=1
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^g"
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Cut
Selection.MoveRight unit:=wdCell
Selection.Paste
Selection.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
Next oILS
End Sub
to work out one small problam .
The aim is to locate all InlineShapes, split the table cell they are in and
move them to the new cell .
I've got it working but it seems to act on the forst image twice ! ,
if I select anything after the first image then run the macro everything is
ok !
I can't seem to work out why ?
maybe there is a better way to do the same action.
Chris
Sub SplitCellsWithImg()
' Find All InlineImages and split the cell
' then move the Inline to the new cell
Dim oILS As InlineShape
Dim oRg As Range
For Each oILS In ActiveDocument.InlineShapes
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^g"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Cells.Split NumRows:=1, NumColumns:=2,
MergeBeforeSplit:=False
Selection.MoveLeft unit:=wdCharacter, Count:=1
Selection.MoveRight unit:=wdCharacter, Count:=11
Selection.MoveLeft unit:=wdCharacter, Count:=1
Selection.MoveRight unit:=wdCharacter, Count:=1
Selection.MoveLeft unit:=wdCharacter, Count:=1
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^g"
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Cut
Selection.MoveRight unit:=wdCell
Selection.Paste
Selection.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
Next oILS
End Sub