Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Apr 2002
    Location
    Mississauga, Ontario
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Opening a TXT file with a specific template (Word 2000 SR01)

    I'm trying to set up an automation procedure to open a TXT file using a specific template which is pre-formatted and then save it as a Word document. This is my first attempt in working with Word templates and automation ( I've done this in Excel quite successfully).

    Question1: How do you open a file so that it uses the proper template (in this case Report Import.dot), instead of Normal.dot?

    Question2: Can I set up scripting to open the file using the correct template when double-clicking from Explorer? - How would I code this?

    Ultimately, my goal is to call Word from a VBS script to open a series of TXT files, format them and save them as DOC files. This will make them more user manageable.
    Because these files were originally printed on a line printer, they don't fit a standard page, so here's what I set up in the Report Import.dot :

    1. Set margins all around to .5 "
    2. Set Default font to Courier New 9 point

    I still need to handle the open dialog for the FIle Conversion option, and the SaveAs dialog. These will be done in VBA.

    Thanks,
    Leslie

  2. #2
    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: Opening a TXT file with a specific template (Word 2000 SR01)

    > Question1: How do you open a file so that it uses the proper template (in this case Report Import.dot),
    > instead of Normal.dot?

    You can't but you can assign a new template to it after it opens.

    ActiveDocument.AttachedTemplate = FileName

    You can experiment with different methods for applying the particular settings of the template to the document; for the most part, it is not automatic.

    > Question2: Can I set up scripting to open the file using the correct template when double-clicking from
    > Explorer? - How would I code this?

    I can't think of any way to do this, particularly if you want .TXT files to continue opening in Notepad in all other cases.

  3. #3
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening a TXT file with a specific template (Word 2000 SR01)

    Hi Leslie & Jefferson:
    I have the of an idea that might work, but I haven't thought it through completely.
    1. It is possible to go to the file associations dialog box (View/Folder Options, etc., depending on the Windows version) add another action for text files. For example, you could add an action of "Open with Word".
    2. You could assign that new action to
    <winword filepath> /mMacroName. When you right clicked on a text file in Explorer, that option would show up. Selecting it would open the file with Word & run the macro called MacroName.
    3. Now the hard part for Jefferson. <img src=/S/grin.gif border=0 alt=grin width=15 height=15> Is it possible to have that macro switch templates, so that a specified template would be attached to the text file? And Leslie, would this serve your purpose?

  4. #4
    Star Lounger
    Join Date
    Jan 2001
    Posts
    68
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Suggestion: use SENDTO Folder

    The simplest approach might be to define a new shortcut in the SENDTO folder. The shortcut could run your VBS script against the file. A variant would be to open the file in Word with a command switch that runs your script as a macro. As noted in the other posts, the script could manipulate the file as needed including setting the template.

    The advantage of the SENDTO folder approach is that you don

Posting Permissions

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