PDA

View Full Version : Add-in sheet



CicoMico
06-21-2007, 05:35 AM
Hello! is there any way to make excel add-in (xla) that will show own sheet? i want to design excel add-in, which will contain sheet1 with some custom controls (multipage) and then if user loads this add-in, it'll show these controls. thanx

xld
06-21-2007, 05:53 AM
Add a custom toolbar




Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.CommandBars("myToolbar").Delete
On Error GoTo 0
End Sub

Private Sub Workbook_Open()
Dim oCB As CommandBar
Dim oCtl As CommandBarControl

On Error Resume Next
Application.CommandBars("myToolbar").Delete
On Error GoTo 0

Set oCB = Application.CommandBars.Add(Name:="myToolbar", temporary:=True)
With oCB
Set oCtl = .Controls.Add(Type:=msoControlButton)
With oCtl
.BeginGroup = True
.Caption = "savenv"
.OnAction = "savenv"
.FaceId = 27
End With
Set oCtl = .Controls.Add(Type:=msoControlButton)
With oCtl
.Caption = "savemyprog"
.OnAction = "savemyprog"
.FaceId = 28
End With
Set oCtl = .Controls.Add(Type:=msoControlButton)
With oCtl
.Caption = "macro4"
.OnAction = "macro4"
.FaceId = 29
End With
Set oCtl = .Controls.Add(Type:=msoControlButton)
With oCtl
.Caption = "dater"
.OnAction = "dater"
.FaceId = 30
End With
.Visible = True
.Position = msoBarTop
End With

End Sub


To add this, go to the VB IDE (ALT-F11 from Excel), and in
the explorer pane, select your workbook. Then select the
ThisWorkbook object (it's in Microsoft Excel Objects which
might need expanding). Double-click the ThisWorkbook and
a code window will open up. Copy this code into there,
changing the caption and action to suit.

CicoMico
06-21-2007, 06:01 AM
hmm... thanx, but.... that's not what i'm trying to do... need to design multipage with labels, controls etc... and let the sheet to show...

xld
06-21-2007, 06:14 AM
It may not be what you thought of, but it is the way that professional developers build their addins.

What is wrong with it?

CicoMico
06-21-2007, 06:22 AM
need to create multipage with some other interface...

xld
06-21-2007, 06:25 AM
But why?

As I said, that is not the way professionals do it, so why is your way so much better, or necessary?

CicoMico
06-21-2007, 06:29 AM
i am working on complete application. i want to hide default tolbars, menus, tabs... and then show new designed interface. this interface will contain multipage control with tabs with custom options...

xld
06-21-2007, 06:34 AM
Then it seems to me that you should be

a) doing it in VB

b) using userforms.

CicoMico
06-21-2007, 06:38 AM
hmm... i know, but i don't have vb :( i was thinking about using forms, but they are floating... i wanna have them on one place...

xld
06-21-2007, 06:58 AM
Excel is floating too?

CicoMico
06-21-2007, 07:08 AM
nop. so should i hide excel and design my own application using userform?

lucas
06-21-2007, 07:24 AM
What Bob is trying to communicate to you is that you can have your multipage controls in an addin without any sheets...just go to the visual basic editor and insert a userform and add your controls...when saved as an addin these controls, menu's ect will be available....

why would you wish to put the controls on a sheet is the question...? There is no reason is the answer.

CicoMico
06-21-2007, 11:50 PM
ok, ok... :yes i got it... so basically what you all say is to design form on the fly? if so, any tuts on that? or would it be better to design it as suggested by lucas? thanx

xld
06-22-2007, 01:06 AM
IF by ... on the fly ... you mean adding controls frok within the userform code itself, then no I don't mean that. I mean design a form as normal, with the relevant controls and actions, and if you want to prtend that it isn't Excel, just hide the application.