PDA

View Full Version : visual basic 6.0 word automation



smnathan
09-04-2004, 03:37 AM
I need to do the following automation using visual basic 6.0. I have to extract one particular section of the word document and insert in to another one word documents particular section and save it. Both the word documents doesn't have any bookmarks. If any one knows or have any idea, how to do that , please help me. Thanks in advance.

Foe example

Doc 1

Heading
1.1 Description

Ahsjkdhjkasjkdhkjaskdjhajsdhjhasjdhjasd

1.2 Server Details
a
b
g
1.3 ???????????


Doc 2
Heading
1.1 H1

1.2 H2

1.3 H3

1.4 H4

1.5 H6


Now I have to move the section 1.2 in doc1 to section 1.4 of doc2 using visual basic.

Both the document doesn?t have any book marks.

village_alchemist
09-04-2004, 08:31 AM
Is there anything distinctive about the headings? For instance, each heading is defined as a separate section, the headings are formatted using a specific style, etc. Or is it just plain, unpredictable text?

Second, are you looking to prompt for which heading to grab text from and where to place it or will that always be the same like your section 1.2 text to section 1.4?

smnathan
09-05-2004, 10:10 PM
Thanks for your reply

1.Most of the Heading are formated with specific style and some are unpredictable text.

2.Always we have to move same section of one document to another one document ie 1.2 to 1.4. Like that i have to move some 10 specific section (only the content) from one document to another documents specific section .

Anne Troy
09-05-2004, 10:20 PM
smnathan:

If I could see one or two of these documents, I could probably help figure out how we can get *there*, where ever *there* happens to be in your files.

As for going through all the docs, we have a couple of Word codes in our knowledgebase (http://www.vbaexpress.com/kb) that *process all documents in a folder*, and I'm sure you'll be able to get that part worked out, right?

So, could you upload a doc or two? Or if confidential, maybe you can send me one or two to anne@ this website?

village_alchemist
09-07-2004, 05:20 AM
There is a code sample in the Micosoft Knowledgebase that will find text based on a style setting: http://support.microsoft.com/default.aspx?scid=kb;[LN];306338 and DrJ has a nice entry in *OUR* Kbase to search for text in a document: http://www.vbaexpress.com/kb/getarticle.php?kb_id=158 Hopefully one of these will help.

village_alchemist
09-07-2004, 06:01 AM
I just read a great little routine that Tony uploaded to find bracketed text on this thread: http://www.vbaexpress.com/forum/showthread.php?t=881 You should be able to modify this to find the text you are looking for.

Oh, and I noticed that part of the micorsoft link didn't get included. You need to include the [LN];306338 with the rest of the link.

smnathan
09-09-2004, 05:59 AM
Hi
I am senting you the document sample to your mail id with brief about my requirment.
Thanks
Regards
Nathan

Anne Troy
09-09-2004, 10:13 AM
Hi, smnathan. I received your files, and I have what I believe is bad news. Can you tell me how many documents must be done? These documents are not properly formatted. While they use styles, some of them have paragraph returns that take the content to the next page, instead of proper page breaks or other formatting that accomplish this task PROPERLY. So, for instance, if you MOVE a paragraph out of Doc1, it has the potential of destroying all page breaks throughout the rest of the document. If you MOVE a paragraph INTO Doc2, same thing.

I suggest you go back to the powers that be and tell them to invest in proper formatting of the documents before they proceed any further. Then, automation can be easily performed when it is again required.

smnathan
09-11-2004, 12:52 AM
Hi,


Thanks for your reply.
I will send you the code, which I have written to automate the process i said. Its working, but its taking lot of time to generate a document. I will send you the code after finishing it completely.

Short description of what i did: -

I iterate through the paragraphs of doc1 and find what section i have to move(copy to doc2) with the heading(style <> normal). I will store the section starting and ending position. After completely reading the first document, open second document (book2) and copy all the section (with starting and ending points) to the concerned location.

Bye
Nathan.S.M