Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-16-2011, 10:57 PM
Jaymond Flurrie Jaymond Flurrie is offline Before the table but after beginning of doc? Windows 7 64bit Before the table but after beginning of doc? Office 2010 32bit
Novice
Before the table but after beginning of doc?
 
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
  #2  
Old 06-19-2011, 04:58 PM
macropod's Avatar
macropod macropod is offline Before the table but after beginning of doc? Windows 7 64bit Before the table but after beginning of doc? Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 08-16-2011, 06:27 AM
DugganSC DugganSC is offline Before the table but after beginning of doc? Windows XP Before the table but after beginning of doc? Office 2007
Novice
 
Join Date: Aug 2011
Posts: 8
DugganSC is on a distinguished road
Default

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.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Before the table but after beginning of doc? Powerpoint loops, but not to beginning imeister PowerPoint 1 02-02-2011 02:05 PM
Before the table but after beginning of doc? 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
Before the table but after beginning of doc? 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

Other Forums: Access Forums

All times are GMT -7. The time now is 04:30 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft