Hi, I'm creating a project that will write in word document, i want to add layout, i create a table with 2 columns & 1 rows. Now my problem is, how can i create another table in inside the cell of my first table.
Anybody can help please regarding this problem???
here is my code:
Public Sub WriteFO(RecordHandler As ADODB.Recordset, wdPath As String)
If Dir(wdPath, vbDirectory) <> "" Then
'ctr = CountExcelRows(ExcelPath) + 1
Else
FileCopy App.Path & "\tmp\Temp.doc", wdPath
End If
Dim ImageFilename As Variant
'Word Declaration
Dim wordApp As Word.Application
Dim wordDoc As Word.Document
Dim wordDoc1 As Word.Document
'Initialize Word
Set wordApp = New Word.Application 'CreateObject("Word.Application")
Set wordDoc = wordApp.Documents.Open(wdPath, , True)
Do While Not (RecordHandler.EOF)
'Download Images
ImageFilename = Split(RecordHandler.Fields("ILink"), "/")
DownloadURL RecordHandler.Fields("ILink"), My & "\rsc\" & ImageFilename(UBound(ImageFilename))
'Insert Details
Dim wordTable As Word.Table
Dim wordTable1 As Word.Table
Set wordTable = wordDoc.Tables.Add(wordDoc.Bookmarks.Item("\endofdoc").Range, 1, 2)
Set wordTable1 = wordTable.Tables.Add(wordDoc.Tables, 2, 1)
wordTable.Range.ParagraphFormat.SpaceAfter = 6
wordTable.Cell(1, 1).Range.InlineShapes.AddPicture My & "\rsc\" & ImageFilename(UBound(ImageFilename)), False, True, wordTable.Range
'wordTable.Cell(1, 2).Range.Text = RecordHandler.Fields("ILink")
wordTable.Cell(1, 2).Range.Tables.Add wordTable1.Range, 2, 1
'wordTable.Cell(1, 2).Range.Tables.Add wordTable1.Range, 3, 1
'Insert New Table
Dim wordPar2 As Word.Paragraph
Set wordPar2 = wordDoc.Content.Paragraphs.Add
wordPar2.Range.Text = vbNewLine
'wordPar2.Range.Font.Italic = True
wordPar2.Range.InsertParagraphAfter
'Colum Resize
wordTable.Columns.Item(1).AutoFit
wordTable.Columns.Item(2).AutoFit
'Hide Borders
Hideborders wordTable
RecordHandler.MoveNext
Loop
wordDoc.SaveAs "C:\Sample.doc"
wordDoc.Close True
wordApp.Quit True
Set wordDoc = Nothing
Set wordApp = Nothing
End Sub
any idea appreciated!!!