PDA

View Full Version : Remember Toolbar Position



Djblois
04-24-2007, 06:04 AM
I am trying to get it so when a user updates my add-in the toolbar stays where the user wants it. I am using this code but it doesn't work on install, only if I run the sub by itself:

Sub CreateToolBar()
On Error Resume Next
Set obj = CommandBars("Business_Reporting_Today")
If Err.Number = 0 Then
With ThisWorkbook.ActiveSheet
.[I5].Value = obj.Top
.[I6].Value = obj.Left
End With
End If
obj.Delete

With ThisWorkbook.ActiveSheet
ntop = .[I5].Value
nleft = .[I6].Value
End With

'define toolbar
Set Tbar = CommandBars.Add
With Tbar
.Name = "Business_Reporting_Today"
.Visible = True
.Position = msoBarTop
.Top = ntop
.Left = nleft
End With

Range("I5:I6").Delete
End Sub

Bob Phillips
04-24-2007, 06:16 AM
Sub CreateToolBar()
Dim obj As CommandBar
Dim TBar As CommandBar
Dim nTop As Long, nLeft As Long, nRowIndex As Long
On Error Resume Next
Set obj = CommandBars("Business_Reporting_Today")
If Err.Number = 0 Then
With ThisWorkbook.ActiveSheet
.Range("I5").Value = obj.Top
.Range("I6").Value = obj.Left
.Range("I7").Value = obj.RowIndex
End With
End If
obj.Delete

With ThisWorkbook.ActiveSheet
nTop = .Range("I5").Value
nLeft = .Range("I6").Value
nRowIndex = .Range("I7").Value
End With

'define toolbar
Set TBar = CommandBars.Add
With TBar
.Name = "Business_Reporting_Today"
.Visible = True
.Position = msoBarTop
.RowIndex = nRowIndex
.Top = nTop
.Left = nLeft
End With

Range("I5:I6").Delete
End Sub

Djblois
04-24-2007, 06:47 AM
XLD,

That is also not working when I install the add-in. It only works if I run the sub by itself.

Bob Phillips
04-24-2007, 07:00 AM
maybe post the add-in?

Djblois
04-24-2007, 07:05 AM
The Website doesn't allow addins to be posted. I have tried in the past.

Bob Phillips
04-24-2007, 07:06 AM
put it in a zip file and you can

Djblois
04-24-2007, 09:16 AM
Here is my full add-in. Have fun. It is quite large and I thank all of you for your help. Xld. I tried it is too large can I email it to you in a zip file?

Bob Phillips
04-24-2007, 11:47 AM
Try uploading it to cjoint.com

Djblois
04-24-2007, 12:24 PM
cjoint is completely in spanish. sorry I don't speak spanish, I have enough trouble with english. Jk

Bob Phillips
04-24-2007, 01:59 PM
It's French actually, but it is pretty obvious.

Just click the button marked Browse and then go and select your file, then click the "Cr?er le lien Cjoint" button. This will give you a URL you can post.

Djblois
04-24-2007, 02:07 PM
http://cjoint.com/?eyxgI0uQk6 (http://cjoint.com/?eyxgI0uQk6)

I think that is it