p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 30th, 2003, 07:54 AM
Registered User
Points: 19, Level: 1
Points: 19, Level: 1 Points: 19, Level: 1 Points: 19, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Finding a heading in a word document

Another question:
I want to store the last heading before the caret position(insertionpoint) in a variable. I've done this by starting at the top of the document and search down to the caret(Selection.start) and check all the words on the way down. This works, but I think it would be easier and time saving to start at the caretposition in the text and search upwards in the text and store the first heading I meet. But is this possible to do? I really need help on this one!

here's my code so far:

'each word
Dim MyWord As Rang

'variable to store the sum of characters of the checked words
Dim number As Long  
number = 0

'variable to store the number of characters from the beginning of
'the text to the caretposition
Dim number3

'Assigning the value
number3 = Selection.Start

'Checking each word until I'm at the caretposistion
For Each MyWord In ActiveDocument.Words
number = MyWord.Characters.Count + number
If number >= number2 Then
Exit For
End If

 checking the style of the word
select case MyWord.Style
case "heading1"
  store heading1.......
case "heading2"
  store heading2.....
end select

Next MyWord
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old August 18th, 2003, 05:22 AM
Registered User
Points: 12, Level: 1
Points: 12, Level: 1 Points: 12, Level: 1 Points: 12, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this algorithm:
1. Select all text up to caret
2. Get the Paragraphs collection of Selection
3. For each Item backwards in Paragraphs collection:
   1. Get Style of Item(i)
   2. Test against each wdStyleHeadingx (x = Heading level number)

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding End of Document Larry Landis Word VBA 1 September 12th, 2007 12:31 AM
how to finding the Graphic objects in word doc madhan_needs_help Word VBA 2 August 8th, 2007 11:38 AM
Urgent: Finding meanings of a word using VBA SMI Word VBA 2 March 26th, 2007 09:13 AM
Word Document to PDF BSkelding ASP.NET 1.0 and 1.1 Professional 1 April 28th, 2005 10:25 AM
Checkbox on word document kareltje Excel VBA 3 February 17th, 2005 11:17 AM



All times are GMT -4. The time now is 04:54 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc