tcoombes
09-22-2011, 09:20 PM
I am automating Word from Access and have Opened an existing document and want to add a new table the top.
Set MyWordDoc = MyWordApp.Documents.Open(InFileName)
I select the range at the very top of my doc
Set MyRange = MyWordDoc.Range(Start:=0, End:=0)
If this is a blank line or a paragraph in word then I can add a table
Set MyWrdTbl = MyWordDoc.Tables.Add(MyRange, 4, 3)
However if the Very top of my original word document was itself a table and there was nothing above that in the document my statement
Set MyRange = MyWordDoc.Range(Start:=0, End:=0) has selected the cell of the original table that was at the top of the document.
I then end up with my new table being a table within a table as it gets inserted within that cell
Normally if you actually open a word doc and find the cursor lies within the first cell of a table you can use the enter key and it will shift the table down and give you a working line outside and above that table.
I thought I might be able to do the same in VBA by using sendkeys and{enter} but that does nothing.
Anyone know how to move that top table down so I can select a range above it for my new table.
Set MyWordDoc = MyWordApp.Documents.Open(InFileName)
I select the range at the very top of my doc
Set MyRange = MyWordDoc.Range(Start:=0, End:=0)
If this is a blank line or a paragraph in word then I can add a table
Set MyWrdTbl = MyWordDoc.Tables.Add(MyRange, 4, 3)
However if the Very top of my original word document was itself a table and there was nothing above that in the document my statement
Set MyRange = MyWordDoc.Range(Start:=0, End:=0) has selected the cell of the original table that was at the top of the document.
I then end up with my new table being a table within a table as it gets inserted within that cell
Normally if you actually open a word doc and find the cursor lies within the first cell of a table you can use the enter key and it will shift the table down and give you a working line outside and above that table.
I thought I might be able to do the same in VBA by using sendkeys and{enter} but that does nothing.
Anyone know how to move that top table down so I can select a range above it for my new table.