Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2004

Tip: Looking for answers? Try searching our database.

Putting same text for multiple lines

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeff - 23 Nov 2004 21:09 GMT
Hello,

I am very used to Access & Excel VBA.  I never worked with Word VBA.

I have 2 questions..

1) How can I reference a specific line ?  Meaning for example display a
Msgbox with the text that is on line 57

2) How can I put the same text lets say for 20 lines ?
For r=1 to 20
    ' what code to write "hello" on each line

Next r

Any help would be greatly appreciated.

Thank you,
Jeff
Helmut Weber - 23 Nov 2004 21:50 GMT
Hi Jeff,
question 1, if it refers to the main story of a document.
With Selection
  .GoTo what:=wdGoToLine, _
  which:=wdGoToAbsolute, _
  Count:=5
  MsgBox .Bookmarks("\line").Range.Text
End With
>2) How can I put the same text lets say for 20 lines ?
The problem is _line_ !
As what makes up a line is calculated dynamically,
depending on font, paper size, printer, selection position
and almost everything.
Inserting 20 paragraphs with "some text" could look like this:
Dim i As Integer
With Selection
  .ExtendMode = False
  .HomeKey unit:=wdLine
  For i = 1 To 20
  .InsertAfter "some text " & vbCr
  Next
End With
---
HTH
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.