Results 1 to 15 of 15

Thread: Script to copy information in word into another doc?

  1. #1
    Registered User
    Join Date
    Feb 2004
    Posts
    12
    Thanks
    0
    Thanked
    0 times in 0 posts

    Script to copy information in word into another doc?

    Hey guys,

    I have a problem and don’t know how to go about it, or if it is even possible to do.
    At work we have a load of blank template documents that we have to input data into for the various projects that we do. There are about a maximum of 10 documents in the folder, so we have to open all of the documents up and input the same information in all of them, in the boxes that are there, what I was asked to do was create something that when clicked opened them all at once, well I did this easy, just made a simple batch file, but the hard part is making something that when project information is entered in say the first document it will be automatically transferred into the other open documents, saving a lot of well needed time.

    So what do you think are my options? Is there some kind of handy function in word that does this? Could I make some kind of crude VB app? Or a simple macro might do? I really don’t know where to start.

    Thanks for your help, I really appreciate it.

  2. #2
    Comfortably Numb directhex's Avatar
    Join Date
    Jul 2003
    Location
    /dev/urandom
    Posts
    17,074
    Thanks
    228
    Thanked
    1,027 times in 678 posts
    • directhex's system
      • Motherboard:
      • Asus ROG Strix B550-I Gaming
      • CPU:
      • Ryzen 5900x
      • Memory:
      • 64GB G.Skill Trident Z RGB
      • Storage:
      • 2TB Seagate Firecuda 520
      • Graphics card(s):
      • EVGA GeForce RTX 3080 XC3 Ultra
      • PSU:
      • EVGA SuperNOVA 850W G3
      • Case:
      • NZXT H210i
      • Operating System:
      • Ubuntu 20.04, Windows 10
      • Monitor(s):
      • LG 34GN850
      • Internet:
      • FIOS
    this is the kind of thing you'd use VBA (Visual Basic For Applications) for. i.e. one big-ass macro.

  3. #3
    Registered User
    Join Date
    Feb 2004
    Posts
    12
    Thanks
    0
    Thanked
    0 times in 0 posts
    ok right, so how would I go about making this? I dont know how to make macros in VB and integrate it with another program i.e Word

  4. #4
    HEXUS.net Webmaster
    Join Date
    Jul 2003
    Location
    UK
    Posts
    3,108
    Thanks
    1
    Thanked
    0 times in 0 posts
    Could use an Access database and put fields in the Word documents which are linked to the columns in the database. That way you enter the data in the database and the Word documents are automatically created.

    Also, don't the latest versions of Word enable the use of XML tags ? You could write some code to populate the fields by passing an XML message into it if that's the case

    You would need some advanced knowledge of Word though

  5. #5
    Large Member
    Join Date
    Apr 2004
    Posts
    3,720
    Thanks
    47
    Thanked
    99 times in 64 posts
    I'm not entirely sure what you want. If they are 10 identical blank documents, cant you just fill one out and save it 10 times?
    To err is human. To really foul things up ... you need a computer.

  6. #6
    Commander Keen
    Join Date
    Nov 2003
    Location
    217.27.240.214
    Posts
    624
    Thanks
    0
    Thanked
    0 times in 0 posts
    i think a dedicated app for this. with a db for data. Particularily those that are linked across documents...This db records all the documents that need each field somewhere.

    Then a program that lets u edit these fields. <- pretty much the same idea as Az, having read his post again

    When u want to generate the full blown word documents ? this can be done in VB apparently. there is some way to "export to word format".. a friend of mine worked on getting raw text converted to word docs using this function recently...

    ACTUALLY. a quick google unearthed this that might be useful.. i can't recommend it since I haven't used it. But it seems to deal with at least some of the issues. Hope it helps

    looky here

  7. #7
    TiG
    TiG is offline
    Walk a mile in other peoples shoes...
    Join Date
    Jul 2003
    Location
    Questioning it all
    Posts
    6,213
    Thanks
    45
    Thanked
    48 times in 43 posts
    Sounds like you are saying Mail Merge to me, wouldn't that be do-able?

    TiG
    -- Hexus Meets Rock! --

  8. #8
    Registered User
    Join Date
    Feb 2004
    Posts
    12
    Thanks
    0
    Thanked
    0 times in 0 posts
    cheers killgORE! thats a great site

    one more thing, my boss has changed the spec, now he wants me to make some kind of program that enables you to input the project information into it, such as project name, location etc, and then click a button that creates a dir with the project name you entered and a load of word documents that are pre formatted so they have the info you just put in put into the docuements aswell...

    hope you got all that guys.. now im really stuck :S

  9. #9
    Comfortably Numb directhex's Avatar
    Join Date
    Jul 2003
    Location
    /dev/urandom
    Posts
    17,074
    Thanks
    228
    Thanked
    1,027 times in 678 posts
    • directhex's system
      • Motherboard:
      • Asus ROG Strix B550-I Gaming
      • CPU:
      • Ryzen 5900x
      • Memory:
      • 64GB G.Skill Trident Z RGB
      • Storage:
      • 2TB Seagate Firecuda 520
      • Graphics card(s):
      • EVGA GeForce RTX 3080 XC3 Ultra
      • PSU:
      • EVGA SuperNOVA 850W G3
      • Case:
      • NZXT H210i
      • Operating System:
      • Ubuntu 20.04, Windows 10
      • Monitor(s):
      • LG 34GN850
      • Internet:
      • FIOS
    erm... forgive my naiveity, but full office 2003 comes with a program called "infopath", pretty sure it's exactly what you need...

  10. #10
    Large Member
    Join Date
    Apr 2004
    Posts
    3,720
    Thanks
    47
    Thanked
    99 times in 64 posts
    Your boss is asking you to do this and you don't know how? In what line of work are you in exactly?
    To err is human. To really foul things up ... you need a computer.

  11. #11
    Commander Keen
    Join Date
    Nov 2003
    Location
    217.27.240.214
    Posts
    624
    Thanks
    0
    Thanked
    0 times in 0 posts
    php web interface to the database... just a massive form.. one text box for text input like project name.. radio buttons for single choice etc..

  12. #12
    Senior Member
    Join Date
    Sep 2003
    Posts
    254
    Thanks
    0
    Thanked
    0 times in 0 posts
    I've done a lot of this kinda VBA for word stuff. You can do it all in a Word template. VBA is practically the same as VB at the end of the day. Or you can write a VB app to do it either and use word from with VB as an object. I don 't suppose theres any money in this is there?

  13. #13
    Registered User
    Join Date
    Feb 2004
    Posts
    12
    Thanks
    0
    Thanked
    0 times in 0 posts
    As an answer to yamangman I work for a comapny called Andover Controls, and I like to play around with VB and stuff but dont know much about it, its like a hobby, my boss knows that and thought i could help him out in someway, its not to do with my job, its kind of a pet project.

    how would i go about making a word template that does that then sparky191? Can i do it in word 97 :S they have given a old busted laptop, im waitin for a new one, but untill then thats all i have to work with... Cheers for the help.

  14. #14
    Large Member
    Join Date
    Apr 2004
    Posts
    3,720
    Thanks
    47
    Thanked
    99 times in 64 posts
    I hate describing these sort of things, so i'm gonna keep it simple sorry.

    First, this would be easier using the cells in Excel.

    What you want to do is record a macro of you entering the data into one of the doucments.

    Take that macro, and include it in 9 other modules for each of the other documents, pointing to their location on the harddisk.

    Use this code in a seperate doucment with a button you can press which will copy this data to each document.

    Or

    Write out each 'box' of information on serperate lines in a word document, use VB code so that, when you click a button in the document, each document is opened and each line is copied to its respective field.

    But, if the documents are all the same (you havn't said if they are) why can't you fill out one a save it 10 times?

    Or you could do it as some kind of input box method, which I have done recently for a (very) simple excel system.

    e.g.

    Sheets("Quote").Select
    Cells(1, 1).Select

    Cells(2, 7).Value = InputBox("Enter date in the format: DD/MM/YY")
    Cells(7, 3).Value = InputBox("Enter customer surname:")
    Cells(9, 3).Value = InputBox("Enter customer forename:")
    Cells(7, 5).Value = InputBox("Enter address (street):")
    Cells(9, 5).Value = InputBox("Enter address (town/city):")
    Cells(11, 5).Value = InputBox("Enter post code:")
    Cells(7, 7).Value = InputBox("Enter telephone number:")

    whatever string is typed in each inputbox is transferred to the corresponding cell.
    Last edited by yamangman; 08-08-2004 at 06:44 PM.
    To err is human. To really foul things up ... you need a computer.

  15. #15
    Senior Member
    Join Date
    Sep 2003
    Posts
    254
    Thanks
    0
    Thanked
    0 times in 0 posts
    Word 97 VBA is based on VB5 rather than VB6 as later versions of Office are. So there not real problem using Word 97, you might have to write some extra code if you need a function thats in VB6 and not in VB5, like to split a string or something like that.

    Some basic lessons

    There are two types of word files. A word document (.doc) and a word template (.dot). By default every word document has a default template attached to it called normal.dot. However you can create and attach other templates if you like, Andover.dot for example.

    All of the power in word is got by using these templates. You can create custom formatting like a company header and footer, save it in a template and if you create a new document based on this template it inherits the custom header and footer of the template.

    You can also record macros, these actually write VBA code for you and are by default saved in the normal.dot. So in many ways you can think of a word template file like a VB project file. You can write modules, sub routines, functions, build forms an even use active X controls etc, and save them all in the template file. Its good practise not to save these in the normal.dot template, unless you want to use them for very document. Good practise is to create a custom template for every project. So you might have a Andover Quotations.dot, and/or a Andover invoice.dot etc.

    A good way when starting out to learn VBA, is to record a macro ("Tools/Macro/Record New Macro") do something like create a table, replace something, move from one place to another, save the doc with a particular filename and location. Then open the VBA editor ("Tools/Macro/Visual Basic Editor") and then look at the code it produces.

    The only problem with this approach is that the macro recorder doesn't record everything. It doesn't record mouse actions for example. It also does everything literally. So it won't tell you how to get to specific cell in a table if you used the mouse to do it. If you tab and use the arrow keys, it will repeat "move right" 16 times etc. You need to learn a bit of Word VBA to program it properly. But looking at what the macro does will get you started.

    Incidentally VBA in every application, Word, Access, Excel is quite different. As each application has functionality that isn't in the others. Theres no worksheet in a word doc for example.

    I'll send you a sample macro (its not complete) to the email addresses in your post. Have a play with that, then email me with any questions, or I can point you in the direction of some word VBA specific forums.

    Or you can just get the boss to give me some money and I'll do it for you, or teach you how to do it! (can't hurt to try eh?) and I'm broke.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Abit NF7-S revision 2 information
    By Lee H in forum SCAN.care@HEXUS
    Replies: 22
    Last Post: 30-10-2004, 07:13 PM

Posting Permissions

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