View Single Post
 
Old 06-16-2011, 10:57 PM
Jaymond Flurrie Jaymond Flurrie is offline Windows 7 64bit Office 2010 32bit
Novice
 
Join Date: Feb 2011
Posts: 13
Jaymond Flurrie is on a distinguished road
Default Before the table but after beginning of doc?

This is most likely extremely simple for you who are experienced Word VBA users:

I print a Word document from Excel VBA (with print I mean I have data in Excel and print that into the Word document), the result being one table in Word. Now at the beginning of this print I don't know the amount of rows this table has, but when the code is finished, I'd like to enter a couple of empty rows on top of the table ie. shifting the table down a bit and write there above the table something like "My table: 30 lines".

Now when I have tried this, it prints the text to the first cell. How do I point a bit earlier spot than that, to beginning of the document instead of that table?

The code I have tried this shift&print with is:
Code:
Sub InsertBeforeMethod()
   Dim MyText As String
   Dim MyRange As Object
   Set MyRange = ActiveDocument.Range
   MyText = "Test"
   MyRange.InsertBefore (MyText)
End Sub
Reply With Quote