Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-18-2017, 05:02 PM
macropod's Avatar
macropod macropod is offline Find This Or That On Line Six of Word Document Windows 7 64bit Find This Or That On Line Six of Word Document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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

Yes, the Word doco on this is lacking. You could use:
Code:
Sub Test()
Dim myRange As Range
Set myRange = ActiveDocument.Range.GoTo(What:=wdGoToLine, Which:=wdGoToAbsolute, Count:=6)
Set myRange = myRange.GoTo(What:=wdGoToBookmark, Name:="\line")
myRange.Select
End Sub
but, when you see what's selected, you'll realise the range often doesn't span the entire line.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 09-18-2017, 11:21 PM
slaycock slaycock is offline Find This Or That On Line Six of Word Document Windows 7 64bit Find This Or That On Line Six of Word Document Office 2013
Expert
 
Join Date: Sep 2013
Posts: 255
slaycock is on a distinguished road
Default

Your code seems to select line 6 OK for me.

I followed the help at

https://msdn.microsoft.com/VBA/Word-...to-method-word

The problem seems to relate to the wdLine constant as

Code:
Set myRange = ActiveDocument.StoryRanges(wdMainTextStory).Characters(1)
myRange.MoveEnd unit:=wdWord
myRange.MoveEnd unit:=wdLine
selects the first word in the document but gives a bad parameter message when the unit is wdLine.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find This Or That On Line Six of Word Document Black line that is in word document that won't go away ! seyzna Word 7 05-22-2023 10:57 AM
Find This Or That On Line Six of Word Document Won't find Word document wblock@cnu.edu Word 4 08-23-2017 06:11 PM
Find This Or That On Line Six of Word Document Cannot find my word document - saved to usb mssodium1219 Word 3 04-01-2015 04:24 AM
Find This Or That On Line Six of Word Document Bad view when using Find and Find & Replace - Word places found string on top line paulkaye Word 4 12-06-2011 11:05 PM
Word 2003 cuts the last line of my document off wordboy9317 Word 0 10-12-2009 08:44 AM

Other Forums: Access Forums

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


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