473,664 Members | 3,028 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 2189

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

Similar topics

0
2697
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 file="global.asp" -->
3
11242
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 have another application that uses a textbox like an editor window and has a save and other buttons. Problem is - when I save/post/reload, the textbox returns to cursor the top again. How can I preserve / save the exact cursor spot and return...
476
18343
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 population thought Jews are morons by heritage, to the point that Jews should be exterminated from earth. Apparently, the entire German population cannot be morons, they must be
18
21804
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 given as an argument to the program. I wrote a small test program that doesn't work because strcmp() fails to find a matching line. Here's the code: #include <stdio.h> #include <string.h> int main(int argc, char** argv)
10
2323
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 too. #include "header.h" /* does the wordwrapping */ void fold(char buffer, int len) {
8
7513
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 same words but in jumbled order they should match and print only the dissimilar lines.The program also checks for multiple entries of the same line. Here file 2 converts to file 3 which is in the format of file1 and i compare file1 with file3.
1
15943
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 reference and it works, however when I add the reference the application can't find it. Not sure why it says the system cannot find the file when it exists in that location? Please help, thanks in advance... GOAL ===========================
6
10291
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 possible, I just can't get JavaScript to work with it. Here is the code I am using, the error I get from IE is Object Expected: Hope someone can help! Any help would be much appreciated
23
4263
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? How is it handled in writing? does text mode has an impact on function returning position within the
0
8861
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8549
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8636
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6187
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5660
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4185
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4351
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2764
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 we have to send another system
2
2003
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.