Results 1 to 11 of 11
  1. #1
    Star Lounger
    Join Date
    Sep 2001
    Location
    Perth, Western Australia
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Collecting & storing user details for re-use (Word

    Hi to all the lounge denizens

    I wonder if someone can help me with this...

    My challenge is to create a template that will be used by a large number of people across a complex network over some 20 sites around Australia, using everything from Word 2000 through to 2003. The basic requirement is that documents based upon the template need to display basic user details (e.g. name, email address, phone number) in the header or footer. So far, no problem - I'd collect the information using Fillin fields (I think?) and simply display the information where it's needed.

    The challenge is doing it in such a way that each user only has to do it once, thereafter each new document based on the template will fetch the details from some store. And of course, there would need to be a facility to change the details at any time.

    So what are the options? My first thought was to use Word's user properties - but they don't offer sufficient flexibility. I figured that it might also be possible to collect the info and store it somehow as variables within the template - but it's possible that some users will be running the template from a server and some locally - not to mention the security issues associated with mixing data with code. So without knowing much about how to actually do something like this, it occurred to me that the ideal way to go about this would be to collect the information and store it locally (perhaps as a text file somewhere foolproof like "My Documents" and maybe even set its "hidden" attribute).

    In the re-use phase, I imagine the macro would first search for the text file in the nominated location. If the file was present, the values would be copied from the various fields into the new document. If the file was not present (i.e. first time the template is used or the file has been deleted), it would simply run the collection macro.

    I have searched for posts that might point me in the right directio, but didn't find anything on the storage & retrieval aspects.

    If anyone has persisted to this point in my ramble, I'd be most grateful - as always - for any suggestions from Team Lounge that might help me put some or all of this solution together.

    Thanks and regards

    Neil

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Collecting & storing user details for re-use (Word

    I'd store the data in a text file using the PrivateProfileString property of the System object. Two examples from the online help for Word VBA:

    Store the path and filename of tue active document in the LastFile setting in the MacroSettings section in the file Settings.txt:

    System.PrivateProfileString("C:Settings.txt", "MacroSettings", "LastFile") = ActiveDocument.FullName

    Retrieve the value of LastFile from Settings.txt, then open the file referred to by LastFile:

    LastFile = System.PrivateProfileString("C:Settings.Txt", "MacroSettings", "LastFile")
    If LastFile <> "" Then Documents.Open FileName:=LastFile

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Collecting & storing user details for re-use (

    If each person will have their own copy of the template, you could accept the data, open the template, and save it in there. However, if the template will be shared (e.g., in the designated Workgroup Templates folder), then this would be a disaster. A local .INI file probably is faster than using database access, and more reliable (fewer privilege issues) than writing to the registry.

    You also could use a plain text file and VB's old file access commands. As long as there are no embedded quotation marks in your data, the "Write #" and "Input #" functions can be used to write and read data, respectively. This is much more work than the INI/registry methods, but if you want the same code to work in both Word and other applications, it might be worth using.

  4. #4
    Star Lounger
    Join Date
    Sep 2001
    Location
    Perth, Western Australia
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Collecting & storing user details for re-use (

    Jefferson hi

    Thanks (as always) for your prompt response. After checking out both your suggestion & Hans', it's clear that the programming side of things is a little beyond my current skills. But now that I have a clue, I'll search the Lounge to see what I snippets I can find & adapt to suit the purpose.

    Best regards

    Neil

  5. #5
    Star Lounger
    Join Date
    Sep 2001
    Location
    Perth, Western Australia
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Collecting & storing user details for re-use (

    Hans

    Thanks (as always) for you prompt response. After checking out both your suggestion & Jefferson's, it's clear that the programming side of things is a little beyond my current skills. But now that I have a clue, I'll search the Lounge to see what I snippets I can find & adapt to suit the purpose.

    Best regards

    Neil

  6. #6
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Collecting & storing user details for re-use (

    Take a look at the code in the attachment of my <post#=505,139>post 505,139</post: >. That'll give you an idea of how to read the entries from an INI file.

  7. #7
    Star Lounger
    Join Date
    Sep 2001
    Location
    Perth, Western Australia
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Collecting & storing user details for re-use (

    Jan hi

    Thanks - yet again. I figured out how to get it going and display the code, but once I selected the lawyer's name from the drop-down list, nothing displayed in the values. Is there supposed to be another macro somewhere to drive the rest of it?

    Once I get this figured out, this looks like it could be just the trick. For security's sake, I think I'd prefer to have the INI file stored in My Documents - presumably that could be done changing the path value from "MacroContainer.Path" to "MyDocuments.Path" or something similar.

    Cheers

    neil

  8. #8
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Collecting & storing user details for re-use (

    Did you [ tab ] out of the drop-down list? As the name suggests, the ExitMacro is only fired upon leaving this formfield.

  9. #9
    Star Lounger
    Join Date
    Sep 2001
    Location
    Perth, Western Australia
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Collecting & storing user details for re-use (

    Jan

    I knew there was a missing piece to that puzzle - thanks. At the risk of stretching a friendship, are you able to steer me towards a corresponding snippet of code somewhere in the lounge that writes data to the INI file (e.g. from FILLIN fields)?

    Thanks again

    neil

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Collecting & storing user details for re-use (

    <post#=242,780>post 242,780</post: > contains an example of code that writes to an .ini file.

  11. #11
    Star Lounger
    Join Date
    Sep 2001
    Location
    Perth, Western Australia
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Collecting & storing user details for re-use (

    Hans

    Many thanks to you, too - I think I have all the pieces of th puzzle now.

    This Lounge rocks!

    Best regards

    Neil

Posting Permissions

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