#1
|
|||
|
|||
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 |
#2
|
||||
|
||||
Hi Jaymond,
Is there a reason you can't simply insert an empty paragraph into the document before you insert the first table?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
If you select a table with something like Table1.Select() and then move up 1 with something like Selection.MoveUp Unit:=wdLine, Count:=1, this will put the cursor right above the table. I used to use that trick to add captions before tables.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Powerpoint loops, but not to beginning | imeister | PowerPoint | 1 | 02-02-2011 02:05 PM |
keep only sentences beginning with: Wind | Michael007 | Word VBA | 3 | 01-17-2011 04:11 PM |
Dash in the beginning of a new line | Wakinyan | Word | 0 | 07-11-2010 07:10 AM |
Add text to the beginning/ending of each line in word | ballmoney | Word | 1 | 01-17-2010 02:19 AM |
Looping macros to add text to beginning and end of a paragraph | pachmarhi | Word VBA | 0 | 02-16-2009 06:57 AM |