PDA

View Full Version : Solved: Excel CommandBars in created session



MountainVogu
07-04-2006, 04:30 PM
Hi

Sorry guys had a good trawl and cant find anything relevent.

The sub below shows the relevent parts of creating a new session of excel and adding a workbook to that session.

Sub x()
Dim xlApp As Excel.Application
Dim xlWbook As Excel.Workbook
Set xlApp = New Excel.Application
xlApp.Application.WindowState = xlNormal
xlApp.Workbooks.Add 'use this line for testing
'ignore
'Set xlWbook = xlApp.Workbooks.Open(ThisWorkbook.Path & "\" & _
'Main.SessionTaskParameters(1, 4), False, True, , , , , , , , False)
xlApp.Application.WindowState = xlMaximized
' ignore during testing
' If DefaultWbook = False Then
' xlApp.Run (xlApp.ActiveWorkbook.Name & "!" & Main.SessionTaskParameters(1, 5))
' End If
Set xlApp = Nothing
End Sub


My problem, no commandbars are visible. I can display and hide the formulabar but setting the commandbars visible and enabled properties does nothing.

I feel sure its a simple thing I'm missing.

Any ideas and many thanks in anticipation

Mv

PS.

Funnily enough I want restricted functionally but I want to be able to add my own menu to the worksheet commandbars. But when I cant even to to get it visible its a little pointless.

Just to clarify this is not a question about adding custom menus to existing excel menus.

austenr
07-04-2006, 07:20 PM
Here is a VB Script way:
Sub x()
Dim objExcel As Object

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
End Sub

This will add your workbook showing the command bars. Someone will be along to help with the limited functionality...

MountainVogu
07-04-2006, 08:30 PM
LOL


Thanks for that Austenr, there was no issue with the restricted functionality thats already in place, the issue was having no commandbars to restrict.

austenr
07-05-2006, 05:57 AM
So you think that's funny huh?

Justinlabenne
07-05-2006, 10:14 AM
Sub x()
Dim xlApp As Excel.Application
Dim xlWbook As Excel.Workbook
Set xlApp = New Excel.Application
xlApp.Workbooks.Add 'use this line for testing
'ignore
'Set xlWbook = xlApp.Workbooks.Open(ThisWorkbook.Path & "\" & _
'Main.SessionTaskParameters(1, 4), False, True, , , , , , , , False)
xlApp.Visible = True
xlApp.WindowState = xlMaximized
' ignore during testing
' If DefaultWbook = False Then
' xlApp.Run (xlApp.ActiveWorkbook.Name & "!" & Main.SessionTaskParameters(1, 5))
' End If
Set xlApp = Nothing
End Sub

MountainVogu
07-05-2006, 02:25 PM
Yep indeed I do, as ever it was something small that I missed.

objExcel.Visible = True

Was the source of my issue, again thanks for pointing that out. Had you needed to make a 400 lines worth of code change, maybe I would not have laughed at myself.

I little testing has also seemed to suggest it depends when you make the app visible.

anywhooos TTFN

austenr
07-05-2006, 05:50 PM
Post Edited by JustinLabenne

MountainVogu
07-06-2006, 01:59 AM
Post Edited by Justin Labenne