Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Mar 2003
    Location
    Liverpool, Merseyside, England
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word Macro (2002)

    I have been tasked with finding a macro that will print then close a word document without allowing the user to save or alter the document in any way. The document is an invoice which is generated by another system, it opens in Word with all the relevant fields completed. Once it's opened, I'd like it to print then close automatically, without allowing the user to change or save it. Is there any way to do this, bearing in mind that my macro skills are very basic indeed! Many thanks for any advice!

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word Macro (2002)

    Yes, this can be done. But you're asking for something beyond your skill level (to which
    you obviously concur). You need a programmer or VBA training.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  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: Word Macro (2002)

    Does the other system have any intelligence regarding Word, or is this more of a text file? Is there any sure-fire way of identifying these and only these files? Are they usually opened from Windows Explorer or from inside Word?

    The reason I ask is: if you lock down the open command so that it immediately prints and closes the document opened, Word loses its utility for everything but this one set of documents. To avoid that problem, you would need to limit your special code either by associating it with the document when it's created, or by identifying the invoices when they are opened.

    Stuff to think about before you actually start writing your macro.

  4. #4
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word Macro (2002)

    Hi Jane

    This idea might be unsuitable for your particular situation, but here goes...
    If you know what kind of printer the invoice recipient uses, you could print the .doc to file (using the appropriate printer driver) and have the recipient simply "send" it to their printer. You could even supply a single-line batch file to accompany it and do the print job for them.

    The .prn file they receive is certainly not a candidate for ready editing, but there are some drawbacks. .PRN files are rather large, so may have to be zipped when sending across a slow network or e-mail. You could "print to file" using a generic text printer driver, which should suit all recipients, but you'd then be downgrading the invoice to a pure text file, which may well not suit.

    Alan

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

    Re: Word Macro (2002)

    Hi Jane:
    I am not a VBA expert, so there may be some flaws in my thinking here, especially since some other VBA experts haven't suggested this. If you password protect your invoice & put the following macro named AutoOpen in it, then it seems to do what you want. However, if the user chooses to disable macros, then they will defeat the macro. However, they will still need to know the password to edit the document. In fact, when I ran it, I was unable to unprotect it. I think that's because my normal.dot contains modified Word Commands for protecting & unprotecting documents.<pre>Sub AutoOpen()
    '
    ' AutoOpen Macro
    ' Macro created 3/23/03 by Phil Rabichow
    '
    ActiveDocument.PrintOut
    ActiveDocument.Saved = True
    ActiveDocument.Close
    End Sub</pre>

    Attached Files Attached Files

  6. #6
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Word Macro (2002)

    If the 'other system' is capable of generating a document and opening it in Word, then this other application is the logical place to locate code to control the printing of the document as well.

    In order to make the document open in an instance of Word, it's likely that this other application is using automation to create an instance of Word. If it is, it's possible to make the instance of Word invisible to the user so that you don't need to worry about the user altering the document.

    What is this other application, and do you have any access to customize the code in it?

    Gary

Posting Permissions

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