elvagonumero1
New Member
- Joined
- Apr 24, 2012
- Messages
- 15
Hello y'all!
I'm smacking my head down with something I'm pretty sure that's simple, but I couldn't find any proper solution for it
I made a code that succesfully paste an excel table to word, this table has four strings with differents text formats an each cell, after pasting I'd like to find the first of four strings ("FOTO") and replace it with a picture stored in the sheet1 of my excel workbook.
The problems are:
1. The pasting starts fine until page 2 where only pastes the table with content skipping the format.
2. I can't find the way to find, using the find method, the "FOTO" string so after selecting it, it'll be overwritten with the Picture mentioned before. I don't know if this is happening because they all it's inside a table.
Here is a piece of the code, give a look please:
I hope someone can help me
Thanks is advance
I'm smacking my head down with something I'm pretty sure that's simple, but I couldn't find any proper solution for it
I made a code that succesfully paste an excel table to word, this table has four strings with differents text formats an each cell, after pasting I'd like to find the first of four strings ("FOTO") and replace it with a picture stored in the sheet1 of my excel workbook.
The problems are:
1. The pasting starts fine until page 2 where only pastes the table with content skipping the format.
2. I can't find the way to find, using the find method, the "FOTO" string so after selecting it, it'll be overwritten with the Picture mentioned before. I don't know if this is happening because they all it's inside a table.
Here is a piece of the code, give a look please:
Code:
If Uf Mod 2 = 0 Then 'Knows itf last row is odd or even
j = Uf \ 2
Else
j = Uf \ 2 + 1
End If
For i = 1 To j
Ws.Range(Ws.Cells((i - 1) * 2 + 1, 1), Ws.Cells(i * 2, 2)).Copy 'takes a 2x2 table from excel to be pasted in word
'---------
'WORD
'---------
.Selection.PasteExcelTable LinkedToExcel:=False, WordFormatting:=False, RTF:=False 'this supposed to paste
'keeping origin's format, this works Okay for the first page only
Application.CutCopyMode = False
Worksheets("sheet1").Shapes("Picture 2").CopyPicture 'copy the picture that is going to replace the "FOTO" string
WordDoc.Content.Find.ClearFormatting
With WordDoc.Content.Find 'I've made three differents alternative of this but any didn't work
.Text = "FOTO"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
WordDoc.Content.Find.Execute
Selection.PasteAndFormat (16)
Next i
'after this the word document is save and blah blah blah!!
I hope someone can help me
Thanks is advance