Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

word from excel, trouble with bookmarks

  Asked By: Bogart    Date: Dec 29    Category: MS Office    Views: 655
  

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.


Sub GenerateDocs()


Dim oWrd As Word.Application
Dim oDoc As Word.Document


Set oWrd = New Word.Application
oWrd.Visible = False


proj = ThisWorkbook.Sheets("DOC").Ran ge("PROJECT_NAME").Value
Set phook = ThisWorkbook.Sheets("DOC").Ran ge("DRAWING_LOC")
Set pdCell = ThisWorkbook.Sheets("DOC").Ran ge("PAD_DESCRIPTION")


Set oDoc = oWrd.Documents.Open("U:\proj44 6\DocTemplate.dot")
oDoc.Bookmarks("ProjName").Ran ge.Text = proj
Set ToCell = oDoc.Bookmarks("PadHook").Rang e
Set TableCell = oDoc.Bookmarks("PdTable").Rang e


With Worksheets("DOC")
.Range(phook).Copy Destination:=ToCell
.Range(pdCell, pdCell.End(xlDown).End(xlToRig ht)).Copy
Destination:=TableCell
End With


oDoc.SaveAs CurDir & "\test.doc"
oDoc.Close


End Sub

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on word from excel, trouble with bookmarks Or get search suggestion and latest updates.




Tagged: