Inserting images into a table, Having trouble inserting in next ce

H

Hendrik

Hi,

I am using late binding and trying to insert e.g. 9 images into a table
(3x3) in Word.

I am having trouble moving to the next cell; VB throws an error on
'wrdSelection.moveright 'Unit:=wdCell' - 'Bad command'. Are there any
specific constants for wdCell or not?

code extract:
---------------

Dim WrdApp As Object
Dim WrdDoc As Object
Set WrdApp = CreateObject("Word.Application")
Dim wrdSelection As Object
Set wrdSelection = WrdApp.Selection
Dim sPic As Object
....

'1st Pic
Set sPic = WrdDoc.InlineShapes.AddPicture(FileName:="C:\1.jpg",
LinkToFile:=False, SaveWithDocument:=True)

'Move on 1 column
wrdSelection.moveright
wrdSelection.moveright
'wrdSelection.moveright 'Unit:=wdCell, Count:=1, Extend:=wdMove 'wdCell
throws err msg 'Bad Command'
'WrdDoc.tables(1).Cell(2, 1).Range.Select ' just selects the column but does
not affect next image insert

'2nd Pic
Set sPic = WrdDoc.InlineShapes.AddPicture(FileName:="C:\1.jpg",
LinkToFile:=False, SaveWithDocument:=True)

.....


Thanks any help would be greatly appreciated!
Cheers,
Hendrik
 
H

Hendrik

Nevermind solved it thanks to a similar post;

Set myRange = WrdDoc.Tables(1).Cell(iWrdCol, iWrdRow).Range
myRange.InlineShapes.AddPicture FileName:="C:\My VB
Projects\Bacchus CMS\Barcodes\" & frmMain.vsData.TextMatrix(iRowLoop,
vsData.ColIndex("Stock_Bar_Code")) & ".jpg", LinkToFile:=False,
SaveWithDocument:=True
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top