473,508 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Microsoft Word VBA Returning the Position of a line

171 New Member
Hi,
I have got a document where there are headings which are always the same, but their sub categories are always different. The Structure is as follows:

Line 1: Heading 1
Line 2: Sub Heading 1-1
Line 3: Sub Heading 1-2
Line 4: Heading 2
Line 5: Sub Heading 2-1
Line 6: Sub Heading 2-2
Line 7: Sub Heading 2-3
Line 8: Heading 3

So basically the information I want to extract out of this is that Sub Heading 1-1 & Sub Heading 1-2 are related to Heading 1, Sub Heading 2-1 , Sub Heading 2-2 and 2-3, are related to Heading 2 and so on.

So in terms of code is there some way we can go
1. Find the position of the first line in the document that = "Heading 1"
Position:Line 1
2. Find the position of the first line in the document that = "Heading 2"
Position:Line 4
3. Line 4 - Line 1 = 3
4. number of lines between Heading 1 and 2 = 3 - 1 = 2
5. Line 1+1 = Line 2 so Line 2 Should be formated like this:
Heading1,Sub Heading1-1
6. Line 1+2 = Line 3 so Line 3 Should be formated like this:
Heading1,Sub Heading1-2
7. Stop adding to Line 1 as we discovered in Point 4 that there are only 2 lines we need to allocate to Heading 1.



I know this is annoyingly complex code, so if you don't have time to go through it could I just get a list of which functions I would need to achieve my objective and then I can research them.
Oct 24 '08 #1
0 2179

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2694
by: Bruce Zigenfous | last post by:
Hello, Here is the code. followed by an explanation for what I am trying to do. In particular, this line: BinaryStream.Write byteArray 'Need to format <%Response.Buffer=0 %> <!--#include...
3
11228
by: jason | last post by:
I've got this javascript routine (i found on google - thank you) in an asp.net page that on page reload sets the cursor of a textbox to the last line. It works great! Using a similar concept, I...
476
18030
by: Xah Lee | last post by:
Microsoft Hatred, FAQ Xah Lee, 20020518 Question: U.S. Judges are not morons, and quite a few others are not morons. They find MS guilty, so it must be true. Answer: so did the German...
18
21698
by: William Payne | last post by:
Hello, I need to write a program that opens a text file and scans the entire file for a specific line and when that line is found, a particular word on that line is to be replaced. The new word is...
10
2308
by: Douglas G | last post by:
I've tried various ideas on this problem, but I don't see word wrapping. Can you point out what is wrong? It's a K&R exercise, and I'm still new to programming. Other pointers would be helpful...
8
7503
by: Frost | last post by:
Hi All, I am a newbie i have written a c program on unix for line by line comparison for two files now could some one help on how i could do word by word comparison in case both lines have the...
1
15921
by: R Reyes | last post by:
ISSUE (reposted) =========================== Can someone please explain to me why I can't get the MS Word Interop assembly to work in my VS2005 project? For many people, they say they add the...
6
10281
by: MayBoy | last post by:
Hi There I am trying to use the Goto method of the Word ActiveX object. I am trying to open a document and go to a named bookmark. If I use this code in VB it works, so I'm sure the approach is...
23
4242
by: O_TEXT | last post by:
When opening a file with open and O_TEXT, in microsoft environment, and then reading it with read, it is done in text mode. What does text mode exactly mean? How is it handled in reading? ...
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
7046
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7498
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3195
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1558
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.