generating report from excel, trouble with bookmark..
Hi all,
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. project name 2. pad drawing 3. 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 that also doesn't work. I don't know what I am doing wrong. 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 = New Word.Application oWrd.Visible = False proj = ThisWorkbook.Sheets("DOC").Range("PROJECT_NAME").V alue Set phook = ThisWorkbook.Sheets("DOC").Range("DRAWING_LOC") Set pdCell = ThisWorkbook.Sheets("DOC").Range("PAD_DESCRIPTION" ) Set oDoc = oWrd.Documents.Open("U:\proj446\DocTemplate.dot") oDoc.Bookmarks("ProjName").Range.Text = proj Set ToCell = oDoc.Bookmarks("PadHook").Range Set TableCell = oDoc.Bookmarks("PdTable").Range With Worksheets("DOC") .Range(phook).Copy Destination:=ToCell .Range(pdCell, pdCell.End(xlDown).End(xlToRight)).Copy Destination:=TableCell End With oDoc.SaveAs CurDir & "\test.doc" oDoc.Close End Sub |
All times are GMT +1. The time now is 06:35 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com