Image in word table cell

This topic contains 0 replies, has 1 voice, and was last updated by Profile photo of Forums Archives Forums Archives 5 years, 3 months ago.

  • Author
    Posts
  • #5157

    by davehook at 2012-10-01 08:50:36

    I create a table in word with cells 1 to 5 coming from a csv, this works fine. In cell 6 I want to place a small png icon (the same one for all records) Any idea how I code this?
    $UserTable =$Word.ActiveDocument.Tables.Add($Word.Selection.Range, 1, 6)
    $UserTable.Cell(1,1).Range.Text = "Post No"
    $UserTable.Cell(1,2).Range.Text = "Force/Contract"
    $UserTable.Cell(1,3).Range.Text = "Last Audit Date"
    $UserTable.Cell(1,4).Range.Text = "Comment"
    $UserTable.Cell(1,5).Range.Text = "Type of Contract"
    $UserTable.Cell(1,6).Range.Text = "status"
    $TableRowPosition = 2
    foreach ($ObjItem in $wordtext) {
    $UserTable.Rows.Add()
    $UserTable.Cell($TableRowPosition,1).Range.Text = $ObjItem.postno
    $UserTable.Cell($TableRowPosition,2).Range.Text = $ObjItem.force
    $UserTable.Cell($TableRowPosition,3).Range.Text = $ObjItem.lastaudited
    $UserTable.Cell($TableRowPosition,4).Range.Text = $ObjItem.comment
    $UserTable.Cell($TableRowPosition,5).Range.Text = $ObjItem.HWR
    $UserTable.Cell($TableRowPosition,6).????image????

    Many thanks

    by surveyor at 2012-10-02 03:57:19

    A quick recording in Word shows this in VBA, maybe it helps?
    Selection.InlineShapes.AddPicture FileName:="D:\Bilder\Logos\AAA.bmp", LinkToFile:=False, SaveWithDocument:=True

    by davehook at 2012-10-03 04:37:20

    Any body tell me what the last line of the above script (for cell 6) would read as im obviously doing this wrong? The image copies multiple times into cel 1, 1

    Thanks

    by davehook at 2012-10-03 05:16:39

    Worked it out

    $UserTable.Cell($TableRowPosition,4).Range.InlineShapes.AddPicture("C:\DiscoveryData\images\greencircle.png")

    thanks all

You must be logged in to reply to this topic.