Hi all,
I have been trying two weeks to find a solution to this problem. I
have posted this in 6+ groups. Unfortunately, I am not able to get some
attention to this problem. I am reposting this again, just incase if
someone finds this problem interesting....Thanks for your kind
attention...
The original problem is as below...
I am trying to generate couple of word documents from excel sheet. I
start with word template file with enclosing bookmarks to insert text
and objects from excel. I have to add three things to the word
document.
1=2E project name
2=2E pad drawing
3=2E table of data
I am able to successfully replace the bookmarks when I use text. But
when I try to copy the drawing(a picture), it doesn't work. Also I try
to copy a table and that doesn't work. I don't know what I am doing
wrong. Or do you have a better suggestion. The code is shown below.
Thanks in advance for correcting me with your suggestions.
shishi
Sub GenerateDocs()
Dim oWrd As Word.Application
Dim oDoc As Word.Document
Set oWrd =3D New Word.Application
oWrd.Visible =3D False
proj =3D ThisWorkbook.Sheets("DOC").Ran=ADge("PROJECT_NAME").Value
Set phook =3D ThisWorkbook.Sheets("DOC").Ran=ADge("DRAWING_LOC")
Set pdCell =3D ThisWorkbook.Sheets("DOC").Ran=ADge("PAD_DESCRIPTION")
Set oDoc =3D oWrd.Documents.Open("U:\proj44=AD6\DocTemplate.dot")
oDoc.Bookmarks("ProjName").Ran=ADge.Text =3D proj
Set ToCell =3D oDoc.Bookmarks("PadHook").Rang=ADe
Set TableCell =3D oDoc.Bookmarks("PdTable").Rang=ADe
With Worksheets("DOC")
.Range(phook).Copy Destination:=3DToCell
.Range(pdCell, pdCell.End(xlDown).End(xlToRig=ADht)).Copy
Destination:=3DTableCell
End With
oDoc.SaveAs CurDir & "\test.doc"=20
oDoc.Close=20
End Sub
Bookmarks