ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ActiveWorkbook.AddToFavorites (https://www.excelbanter.com/excel-programming/423526-activeworkbook-addtofavorites.html)

MeistersingerVonNurnberg

ActiveWorkbook.AddToFavorites
 
Hi -

Anyway to disable .AddToFavorites?

I have a a macro that generates the end-of-month runs. It generates anywhere
from 2 to 70 different workbooks. If there are more, it can "overrun" the
users "favorites" folder.

Thanks

joel

ActiveWorkbook.AddToFavorites
 
This may sound like a lot of work but it is a solution. The problem is you
are limited to the number of Files in a folder. If a user has too many files
in his favorites directory you can't add any more. There are two solutions.
Delete some files from the favorites directory or Add a new Subfolder to the
Favorites. The code below adds a new Subfolder in the persons favorites
called End Of Month. Then after the addtofavorite is executed it moves the
new shortcut to the End of Month Subfolder.

Sub MovetoNewFolder()
Const Addfolder = "End of Month"
Homedrive = Environ("Homedrive")
HomePath = Environ("HOMEPATH")
Favorite = Homedrive & HomePath & "My documents\Favorites"
EndofMonth = Favorite & "\" & Addfolder
Set FSOobj = CreateObject("Scripting.FileSystemObject")

'Test if End of Month folder exists
If Not FSOobj.folderexists(EndofMonth) Then
'create folder end of Month
Set FavoriteFolder = FSOobj.getfolder(Favorite)
FavoriteFolder.subfolders.Add Addfolder
End If

'Save in Faroites
ThisWorkbook.AddToFavorites
'Get new filename
FName = Dir(Favorite & "\" & ThisWorkbook.Name & "*.*")
'set object to new filename
Set ShortCut = FSOobj.getfile(Favorite & "\" & FName)
'move to subfolder
ShortCut.Move EndofMonth & "\" & FName

End Sub

"MeistersingerVonNurnberg" wrote:

Hi -

Anyway to disable .AddToFavorites?

I have a a macro that generates the end-of-month runs. It generates anywhere
from 2 to 70 different workbooks. If there are more, it can "overrun" the
users "favorites" folder.

Thanks


MeistersingerVonNurnberg

ActiveWorkbook.AddToFavorites
 

Hi -

I think the real problem I am having is this: when I execute the wb.save a
bunch of times, it puts a shortcut into "Recent Documents", and that is what
I was referring to regarding "overrunning" favorites. I am reaching no limit;
it just puts so many of the shortcuts there, a user can't see other docs they
were working on.

In other words, after executing my process, under start-documents, there
will be lots of versions of my generated wb.

So, from your post 2 things: 1. delete the shortcuts myself - maybe if some
tolerance is reached, start purging; 2. manage the shortcuts myself - perhaps
w folders - I like this idea you presented very much bc the visibility into
the created wb's is there, and a user can ignore as they desire.

Thanks Joel!


"Joel" wrote:

This may sound like a lot of work but it is a solution. The problem is you
are limited to the number of Files in a folder. If a user has too many files
in his favorites directory you can't add any more. There are two solutions.
Delete some files from the favorites directory or Add a new Subfolder to the
Favorites. The code below adds a new Subfolder in the persons favorites
called End Of Month. Then after the addtofavorite is executed it moves the
new shortcut to the End of Month Subfolder.

Sub MovetoNewFolder()
Const Addfolder = "End of Month"
Homedrive = Environ("Homedrive")
HomePath = Environ("HOMEPATH")
Favorite = Homedrive & HomePath & "My documents\Favorites"
EndofMonth = Favorite & "\" & Addfolder
Set FSOobj = CreateObject("Scripting.FileSystemObject")

'Test if End of Month folder exists
If Not FSOobj.folderexists(EndofMonth) Then
'create folder end of Month
Set FavoriteFolder = FSOobj.getfolder(Favorite)
FavoriteFolder.subfolders.Add Addfolder
End If

'Save in Faroites
ThisWorkbook.AddToFavorites
'Get new filename
FName = Dir(Favorite & "\" & ThisWorkbook.Name & "*.*")
'set object to new filename
Set ShortCut = FSOobj.getfile(Favorite & "\" & FName)
'move to subfolder
ShortCut.Move EndofMonth & "\" & FName

End Sub

"MeistersingerVonNurnberg" wrote:

Hi -

Anyway to disable .AddToFavorites?

I have a a macro that generates the end-of-month runs. It generates anywhere
from 2 to 70 different workbooks. If there are more, it can "overrun" the
users "favorites" folder.

Thanks


joel

ActiveWorkbook.AddToFavorites
 
I don't think they are going into recent documents. In your home directory
under My documents \Favorite is the location where they are going. You can
also see these files if you open an Internet Explorer and look under Favorite.

"MeistersingerVonNurnberg" wrote:


Hi -

I think the real problem I am having is this: when I execute the wb.save a
bunch of times, it puts a shortcut into "Recent Documents", and that is what
I was referring to regarding "overrunning" favorites. I am reaching no limit;
it just puts so many of the shortcuts there, a user can't see other docs they
were working on.

In other words, after executing my process, under start-documents, there
will be lots of versions of my generated wb.

So, from your post 2 things: 1. delete the shortcuts myself - maybe if some
tolerance is reached, start purging; 2. manage the shortcuts myself - perhaps
w folders - I like this idea you presented very much bc the visibility into
the created wb's is there, and a user can ignore as they desire.

Thanks Joel!


"Joel" wrote:

This may sound like a lot of work but it is a solution. The problem is you
are limited to the number of Files in a folder. If a user has too many files
in his favorites directory you can't add any more. There are two solutions.
Delete some files from the favorites directory or Add a new Subfolder to the
Favorites. The code below adds a new Subfolder in the persons favorites
called End Of Month. Then after the addtofavorite is executed it moves the
new shortcut to the End of Month Subfolder.

Sub MovetoNewFolder()
Const Addfolder = "End of Month"
Homedrive = Environ("Homedrive")
HomePath = Environ("HOMEPATH")
Favorite = Homedrive & HomePath & "My documents\Favorites"
EndofMonth = Favorite & "\" & Addfolder
Set FSOobj = CreateObject("Scripting.FileSystemObject")

'Test if End of Month folder exists
If Not FSOobj.folderexists(EndofMonth) Then
'create folder end of Month
Set FavoriteFolder = FSOobj.getfolder(Favorite)
FavoriteFolder.subfolders.Add Addfolder
End If

'Save in Faroites
ThisWorkbook.AddToFavorites
'Get new filename
FName = Dir(Favorite & "\" & ThisWorkbook.Name & "*.*")
'set object to new filename
Set ShortCut = FSOobj.getfile(Favorite & "\" & FName)
'move to subfolder
ShortCut.Move EndofMonth & "\" & FName

End Sub

"MeistersingerVonNurnberg" wrote:

Hi -

Anyway to disable .AddToFavorites?

I have a a macro that generates the end-of-month runs. It generates anywhere
from 2 to 70 different workbooks. If there are more, it can "overrun" the
users "favorites" folder.

Thanks



All times are GMT +1. The time now is 05:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com