DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: How do I specify the active document without looking myself into a specific filename?

  1. #1
    Michael Heavener Guest

    How do I specify the active document without looking myself into a specific filename?


    Recording a macro around the Organizer tool. I need to copy all styles from
    a template into the active document regardless of the active document's filename
    (it could be 'paper_two.doc' or 'Document2', or 'sunk costs and spirituality.rtf',
    or anything else). However, I'm stuck and unable to ferret out any syntax
    that specifies "who cares what the active document's name is, just do it".
    Everything I try returns the following error: "Run-Time error '4149': File
    Not Found. I've learned to hate VBA in Word because for us non-programmers,
    there's simply no way easily learn the things that extend Word's functionality.
    Trial and error is an absolutely screwed up way to make something work, yet
    that's what I'm reduced to doing. VBA's built-in documentation is even more
    inscrutible that the program itself. Needless to say, I'm angry, frustrated,
    and feel I should quit using Word altogether before it forces me to flunk
    out of grad school. I hope someone reads past my rant and sends me the snippet
    of code that will bring the cream to the top of my milk, wax my car, and
    make my computer run at megabits per gallon -- or at least makes my macro
    able to target a global "any document that happens to be open at this time
    and is the active document." In advance, many thanks for your time. Michael,
    heavener@heavenr.com (I hope I haven't inadvertently violated any rules with
    this message. I couldn't find any rules posted, if so, so I apologize in
    advance.)


  2. #2
    Paul Clement Guest

    Re: How do I specify the active document without looking myself into a specific filename?

    On 6 Feb 2002 03:46:16 -0800, "Michael Heavener" <heavener@heavenr.com> wrote:


    Recording a macro around the Organizer tool. I need to copy all styles from
    a template into the active document regardless of the active document's filename
    (it could be 'paper_two.doc' or 'Document2', or 'sunk costs and spirituality.rtf',
    or anything else). However, I'm stuck and unable to ferret out any syntax
    that specifies "who cares what the active document's name is, just do it".
    Everything I try returns the following error: "Run-Time error '4149': File
    Not Found. I've learned to hate VBA in Word because for us non-programmers,
    there's simply no way easily learn the things that extend Word's functionality.
    Trial and error is an absolutely screwed up way to make something work, yet
    that's what I'm reduced to doing. VBA's built-in documentation is even more
    inscrutible that the program itself. Needless to say, I'm angry, frustrated,
    and feel I should quit using Word altogether before it forces me to flunk
    out of grad school. I hope someone reads past my rant and sends me the snippet
    of code that will bring the cream to the top of my milk, wax my car, and
    make my computer run at megabits per gallon -- or at least makes my macro
    able to target a global "any document that happens to be open at this time
    and is the active document." In advance, many thanks for your time. Michael,
    heavener@heavenr.com (I hope I haven't inadvertently violated any rules with
    this message. I couldn't find any rules posted, if so, so I apologize in
    advance.)

    If you could post some of your code and identify the line on which the error occurs it might help us
    do a bit of troubleshooting. Also, I'm not certain what version of Word you are using and that would
    help as well.

    You mention "recording a macro" so I assume that to some extent you are using the built in Macro
    Recorder?


    Paul ~~~ pclement@ameritech.net
    Microsoft MVP (Visual Basic)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center