Dear All,
I have successfully written a programme that links a cell in one .xls file to a cell in another .xls file. I now want to accomplish the same thing using .doc files.
I have created two files, one the source and the other the destination. Both files contain tables with identical numbers of rows and columns. The source file is populated already and I want to link cells in the destination file to cells in the source file.
However, what happens is that the table in the destination file disappears, and the 6 cells from the source file are simply written over each other in the destination file; in the top left hand corner. Furthermore, unlike what occurs in the .xls files, when o Ctrl/click the link, it does not go to the source cell, but to the top left hand corner of the source file.
When I use the “Record New Macro”, it works the way I want it to, and when I study the code produced it is practically identical to mine. So what am I doing wrong? And why does the table in the destination file disappear?
I am using VB.Net 2008.
Regards,
John
I have successfully written a programme that links a cell in one .xls file to a cell in another .xls file. I now want to accomplish the same thing using .doc files.
I have created two files, one the source and the other the destination. Both files contain tables with identical numbers of rows and columns. The source file is populated already and I want to link cells in the destination file to cells in the source file.
However, what happens is that the table in the destination file disappears, and the 6 cells from the source file are simply written over each other in the destination file; in the top left hand corner. Furthermore, unlike what occurs in the .xls files, when o Ctrl/click the link, it does not go to the source cell, but to the top left hand corner of the source file.
When I use the “Record New Macro”, it works the way I want it to, and when I study the code produced it is practically identical to mine. So what am I doing wrong? And why does the table in the destination file disappear?
I am using VB.Net 2008.
Code:
LineItems = 6
i = 1
j = 3
k = 3
WordTableCell = WordFile02.Tables(1).Rows(3).Cells(2)
WordTableCell.Select()
WordObj.Selection.MoveRight()
InvName = WordFile01.Tables(i).Rows(j).Cells(k).Range.Text
InvName = Left(InvName, Len(InvName) – 2)
For x = 1 To LineItems
WordFile01.Tables(i).Rows(j).Cells(k).Range.Select()
WordFile02.Activate()
WordFile02.Hyperlinks.Add(Anchor:=WordFile02.Range,Address:=_ "C:\z\Test01.doc",SubAddress:="WordFile01.Tables(1).Rows(j).Cells(k)",_ TextToDisplay:=CStr(InvName))
j = j + 1
InvName = WordFile01.Tables(i).Rows(j).Cells(k).Range.Text
InvName = Left(InvName, Len(InvName) - 2)
Next
Regards,
John