Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Hiding recently opened files (VBA W97)

    I know that you can prevent a file from being added to the Recently opened files list by putting 'AddtoRecentFiles:=false' in the activedocument.saveas line, but does any one know how to do the equivalent to a document when it's just opened, not saved?

    A template I am working on opens (and closes) other documents during its processing, and I don't want them all to be added to the list.

    Any help would be appreciated!
    Beryl M


  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hiding recently opened files (VBA W97)

    Look at Tools | Options | General | Recently used files list. Clear that option.

  3. #3
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Hiding recently opened files (VBA W97)

    Beryl, Word's Open method also has an AddToRecentFiles parameter. Are you using it? HTH --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  4. #4
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Hiding recently opened files (VBA W97)

    Sam, no, I'm not, because what I want to do is open a document normally (File, Open, choose doc) but have Word know that when that doc is opened it's not to be added to the RecentFiles list ... am I asking too much here?!
    Beryl M


  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Hiding recently opened files (VBA W97)

    Oops! Replied to myself! <img src=/S/doh.gif border=0 alt=doh width=15 height=15>

    Howard, pls see my reply to myself!
    Beryl M


  6. #6
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Hiding recently opened files (VBA W97)

    Thx, Howard, but I knew about that; however, I don't want to switch it off, full stop, just when a particular document is opened - that's why I was hoping for a code version ...

    Perhaps something along the lines of a line that could be added to sub FileOpen - "If activedocument.name = "..." then addtorecentfiles:=false"? Except I can't think how to implement it ... <img src=/S/sigh.gif border=0 alt=sigh width=15 height=15>
    Beryl M


  7. #7
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Hiding recently opened files (VBA W97)

    I think I see. You want the user to be able to use the File, Open menu to open files, but not have the file appear in the recent file list.

    This is just brainstorming: <img src=/S/hmmn.gif border=0 alt=hmmn width=15 height=15>
    1. <LI>Save the RecentFiles collection
      <LI>Set the RecentFiles.Maximun to RecentFiles.Count+1
      <LI>User Opens a file
      <LI>Clear the MRU list (Application.DisplayRecentFiles = False, then set it back to true.)
      <LI>Use the Add method of the RecentFiles collection to add each of the items in the saved list
    Ugly, but might work! --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  8. #8
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Hiding recently opened files (VBA W97)

    Sounds good, Sam (and yes, that is exactly what I want to do) - but your suggestion involves Word doing two things *before* the user opens the file - how does it know to do these when it doesn't know the user is about to open the file that shouldn't be added to the list?!

    <img src=/S/headthrob.gif border=0 alt=headthrob width=15 height=15>
    Beryl M


  9. #9
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Hiding recently opened files (VBA W97)

    Use the Document Open event:
    1. <LI>Press <ALT> <F11> to get to the VBE
      <LI>Double click on ThisDocument for your "project" (template) in the explorer window
      <LI>In the code window, use the left-hand "Object" drop-down to select Document and the right-hand "Procedure" drop-down to select Open
    Now, you have the Open event ready to code. Don't forget to add Option Explicit at the top. Keeps you honest and reduces debug time!
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  10. #10
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Hiding recently opened files (VBA W97)

    Yes - that works! But of course, loses the current list. Your earlier suggestion - of saving the collection and re-adding it - is looking better and better ... and I know I'm being a complete pain, but how would I go about doing that?

    (You can tell I'm self-taught, can't you - there're big holes in my knowledge I didn't even know were there until now ...!)

    Many, many thanks, Sam!
    Beryl M


  11. #11
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Hiding recently opened files (VBA W97)

    Sam, I feel as I'm on the edge of discovering what I want but I just can't figure out the final bit to get there ... The VBE help says that document.open has a property 'addtorecentfiles' which can be set to false (true - I found that one) but how do you apply that to a document_open sub? I thought it would be activedocument.addtorecentfiles but it's not! Aaagh! <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23>

    This is beginning to really get to me!
    Beryl M


  12. #12
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Hiding recently opened files (VBA W97)

    I think you are trying to do too much. The document open event is called after the application (in this case Word) has opened the document. However, this event is only fired when the template is opened, not when the user opens other files.

    Here is a better summary of what needs to happen:

    In your template's document open event:
    1. <LI>Save the RecentFiles collection
      <LI>Optional -- retrieve a recent file list for this template from the registery and replace the RecentFile collection.
    Now, the user works with the template, opening other files as needed. This will add them to the recent files, but we will clean-up later. Finally, the user closes Word which causes Word to do a Save As. User enters a filename and Word saves the file and fires the Close event.

    In your template's document close event:
    1. <LI>Optional -- save the recent file list for the template in the registry.
      <LI>Clear the MRU list (Application.DisplayRecentFiles = False, then set it back to true.)
      <LI>Use the Add method of the RecentFiles collection to add each of the items in the saved list
    Will that work? --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  13. #13
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hiding recently opened files (VBA W97)

    That looks complicated.

    What aboout using sopmething like:<pre>RecentFiles.Item(3).Delete</pre>

    You could reference the item by name rather than exit; or look at every item in the collection, and if the name matches, remove it.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  14. #14
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hiding recently opened files (VBA W97)

    I'm just glancing at this thread; I essayed with the MRU list about eight months back - I was trying to produce a better list than the one limited to 9 entries.

    I had problems (in Word97/VBA) getting MRU-like entries to "stick". If you start coding MRU stuff and it doesn't work, don't spend too much time bashing your herad against a brick wall.

    I may be able to dig out my code from that time if you want it ......

  15. #15
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Hiding recently opened files (VBA W97)

    Thanks, Chris - I'd certainly be interested in seeing the code if it doesn't cause you too much trouble!

    I'm still trying to work this one ...
    Beryl M


Page 1 of 2 12 LastLast

Posting Permissions

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