View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default finding a file in excel

Josh

I don't believe you should be messing around with anyone's Excel *.xlb file.

Create the toolbars when your application opens.

When your application closes, delete the toolbars and restore the user's
original setup without affecting user's *.xlb file

Sub Add_Controls()
Dim i As Long
Dim onaction_names As Variant
Dim caption_names As Variant
onaction_names = Array("macro1", "macro2", "macro3")
caption_names = Array("caption 1", "caption 2", "caption 3")
With Application.CommandBars("Cell")
For i = LBound(onaction_names) To UBound(onaction_names)
With .Controls.Add(Type:=msoControlButton)
.OnAction = ThisWorkbook.Name & "!" & onaction_names(i)
.Caption = caption_names(i)
End With
Next i
End With
End Sub

Sub Delete_Controls()
Dim i As Long
Dim caption_names As Variant
caption_names = Array("caption 1", "caption 2", "caption 3")
With Application.CommandBars("Cell")
For i = LBound(caption_names) To UBound(caption_names)
On Error Resume Next
.Controls(caption_names(i)).Delete
On Error GoTo 0
Next i
End With
End Sub

For more on this see Debra Dalgleish's site.

http://www.contextures.on.ca/xlToolbar02.html

John Walkenbach has a download named MenuMakr which you can incorporate into
your workbook for creating custom menus.

http://www.j-walk.com/ss/excel/tips/tip53.htm


Gord Dibben MS Excel MVP

On Thu, 3 May 2007 12:14:01 -0700, Josh C
wrote:

I think is going to be a hard one. I know Excel 2003 and newer has a file (it
is called “Excel11.xlb” on my computer). In this file Excel saves what
toolbars were visible the last time Excel was shut down. The problem is that
I want to open this file when I am closing a program I have developed. By
opening this file I will restore the toolbars various users have setup on
their Excel. I can already restore built in toolbars, but I want to restore
custom toolbars if any user has set made their own. Excel knows where this
file is located because in accesses it when excel is opened. I know where it
is on my computer, but I can not go around to every ones computer and find
the file and map the location. And I am sure it is not the same name on every
computer. So, if Excel knows where it is, how do I make my program call this
file right before the user closes their program.