Results 1 to 5 of 5

Thread: close window

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2000
    Posts
    157
    is there a way of finding out that there are more than one active window open,
    what i need to do is close a word document that i am working on. which it does.
    but if it is the only word document open then it will only close the document, but if there is another word document open it will close the actual window with the document. in other words it will exit out of word for that particular document.
    but will leave the other documents open.
    i have tried using the active.close option.
    and have tried using application.quit method.
    what i need to do is something like

    if more than one word document open then
    activewindow.close
    else
    application.quit

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    You could try using DDE.
    I have no idea how or what you can do, but things like that can be done through DDE i believe

    - jamie.
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Dec 2000
    Posts
    157
    eh?
    i have never used this before can you give me an example or somewhere i can get more information about this

  4. #4
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    sorry, I know nearly nothing about DDE except that you can use it to communicate with other programs in windows.

    sorry i cant be of anymore help :/

    - jamie
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  5. #5
    Lively Member
    Join Date
    Jun 2000
    Location
    A caravan park in the Midlands (UK)
    Posts
    101

    Cool Similar on Excel


    Not sure on word but on Excel there's a Workbooks collections. This collection contains an entry for each open workbook, thus you can loop through and close/activate whichever one you like.

    I've never looked at automating Word but I'm pretty certain there's a Documents collection. As per excel each item in this is a document object which has the necessary close events (or activate or whatever it is you wish to do).

    Obviously myWord.documents.count would return the number of open documents you have. Have a nose round with the VB Object Browser and you should find what you want. (I presume you've added the Word object library to your app).

    Hope this is of use, I know this is the scenario for Office 2000.
    Anakim

    It's a small world but I wouldn't like to paint it.

Posting Permissions

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



Click Here to Expand Forum to Full Width