Avatar of bradyguy
bradyguy
 asked on

how do you selectively turn on and off toolbars and menus using dsoframer

I am using the dsoframer control from microsoft (unsupported control)  
see http://support.microsoft.com/?kbid=311765

It works as expected I can embed a word document in my windows forms application.  I would like to be able to turn off and on particular toolbars.   The control provides for a global toolbars property which seems to turn on and off the toolbars all of them.  
In theory the following should work in my code below but it does not seem to have any affect.
oDoc.Application.CommandBars("Formatting").Visible = True

Any help would be greatly appreciated.
Public Sub New(ByVal memo As String)

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

        Try




            Me.t_Memo.Text = memo
            If My.Settings.WordAsEditor = True Then
                fc_Memo.CreateNew("Word.Document")

                fc_Memo.Visible = True
                fc_Memo.Dock = DockStyle.Fill
                fc_Memo.BringToFront()
                fc_Memo.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFileNew, False)
                fc_Memo.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFileOpen, False)
                fc_Memo.Toolbars = True

                ' We need to explicitly enable the event sinks. Due to a strange bug in .NET
                ' when the control is sited to tab page and not the main form, it is told to
                ' freeze events (IOleControl) but never told to unfreeze. So events don't get
                ' fired correctly from tab strip. This sets the flag to re-enable the events.
                fc_Memo.EventsEnabled = True
                fc_Memo.Select()
                Me.t_Memo.Visible = False


                oDoc = fc_Memo.ActiveDocument
                With oDoc
                    .ActiveWindow.DisplayRightRuler = False
                    .ActiveWindow.DisplayScreenTips = False
                    .ActiveWindow.DisplayVerticalRuler = False
                    .ActiveWindow.ActivePane.DisplayRulers = False
                    .ActiveWindow.ActivePane.View.Type = Microsoft.Office.Interop.Word.WdViewType.wdWebView
                End With

                oWord = oDoc.Application
                oDoc.Content.Text = memo
            End If

           
            'Try
            '    oDoc.Application.CommandBars("QuickTool").Visible = True
            'Catch ex As Exception
            '    ShowMessage(1, MessageType.UnhandledError, , ex)
            'End Try
            Try
                oDoc.Application.CommandBars("Standard").Visible = False
            Catch ex As Exception
                ShowMessage(1, MessageType.UnhandledError, , ex)
            End Try
            Try
                oDoc.Application.CommandBars("Formatting").Visible = True
            Catch ex As Exception
                ShowMessage(1, MessageType.UnhandledError, , ex)
            End Try
        Catch ex As Exception
            ShowMessage(1, MessageType.UnhandledError, , ex)
        End Try
    End Sub
Web ComponentsEditors IDEsVisual Basic.NET

Avatar of undefined
Last Comment
rachitkohli

8/22/2022 - Mon
rachitkohli

Hello,
Following code worked for me
AxFramerControl1 is the dsoFramer control name


AxFramerControl1.ActiveDocument.commandbars ("Formatting").visible = False

Open in new window

bradyguy

ASKER
I have tested this for a couple of days now and the line of code that you have provided works sporatically.   I have been unable to determine a pattern as to when it works and when it does not work.  the Framer control has a property to turn toolsbars completely off.  For now I have decided to do that until I can come back and see if I can work out the consistency problem with selectively turning on and off certain toolbars.
ASKER CERTIFIED SOLUTION
rachitkohli

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck