+ Reply to Thread
Results 1 to 3 of 3

Reposting to get your kind attention

  1. #1
    shishi
    Guest

    Reposting to get your kind attention

    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


  2. #2
    Debra Dalgleish
    Guest

    Re: Reposting to get your kind attention

    Try doing the copy and paste as separate steps, e.g.:

    With Worksheets("DOC")
    phook.Copy
    ToCell.PasteExcelTable False, False, False


    shishi wrote:
    > 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. 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 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 = 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
    >



    --
    Debra Dalgleish
    Excel FAQ, Tips & Book List
    http://www.contextures.com/tiptech.html


  3. #3
    shishi
    Guest

    Re: Reposting to get your kind attention

    Debra,

    Thanks for the reply. In Office 2000 environment, PasteExcelTable
    comes up with a compilation error of method or datamember found. So I
    am just using the paste method. Thanks for the suggestion.


    Shishi


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1