troubleshooting Question

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

Avatar of bradyguy
bradyguy asked on
Visual Basic.NETWeb ComponentsEditors IDEs
3 Comments1 Solution1224 ViewsLast Modified:
I am using the dsoframer control from microsoft (unsupported control)  

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.

        ' Add any initialization after the InitializeComponent() call.


            Me.t_Memo.Text = memo
            If My.Settings.WordAsEditor = True Then

                fc_Memo.Visible = True
                fc_Memo.Dock = DockStyle.Fill
                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
                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

            '    oDoc.Application.CommandBars("QuickTool").Visible = True
            'Catch ex As Exception
            '    ShowMessage(1, MessageType.UnhandledError, , ex)
            'End Try
                oDoc.Application.CommandBars("Standard").Visible = False
            Catch ex As Exception
                ShowMessage(1, MessageType.UnhandledError, , ex)
            End 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

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros