Consulting

Results 1 to 9 of 9

Thread: visual basic 6.0 word automation

  1. #1
    VBAX Newbie
    Joined
    Sep 2004
    Posts
    5
    Location

    visual basic 6.0 word automation

    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.

  2. #2
    VBAX Regular village_alchemist's Avatar
    Joined
    Jul 2004
    Location
    Michigan, US
    Posts
    32
    Location
    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?

  3. #3
    VBAX Newbie
    Joined
    Sep 2004
    Posts
    5
    Location
    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 .

  4. #4
    Site Admin
    The Princess
    VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    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 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?
    ~Anne Troy

  5. #5
    VBAX Regular village_alchemist's Avatar
    Joined
    Jul 2004
    Location
    Michigan, US
    Posts
    32
    Location
    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.

  6. #6
    VBAX Regular village_alchemist's Avatar
    Joined
    Jul 2004
    Location
    Michigan, US
    Posts
    32
    Location
    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.

  7. #7
    VBAX Newbie
    Joined
    Sep 2004
    Posts
    5
    Location
    Hi
    I am senting you the document sample to your mail id with brief about my requirment.
    Thanks
    Regards
    Nathan

  8. #8
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    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.
    ~Anne Troy

  9. #9
    VBAX Newbie
    Joined
    Sep 2004
    Posts
    5
    Location
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •