Solved

Mord97 and VB

Posted on 1998-10-02
3
150 Views
Last Modified: 2010-04-30
Is there a way to turn off the word97 menu bar from VB. I using VB to launch a document in word, but I don't the user to be able to modify the document. So i need to turn off all the toolbars and the menu bar. Thanks
0
Comment
Question by:mlentini
3 Comments
 
LVL 3

Expert Comment

by:vmano
ID: 1437783
When you activate an OLE container as a Word Document object from within Microsoft Visual Basic, the Toolbars command on the View menu shows Standard, Formatting, and other toolbars selected. However, no toolbars display.

vmano


0
 

Author Comment

by:mlentini
ID: 1437784
Can't use an ole container. for other reasons. must use automation.
0
 
LVL 1

Accepted Solution

by:
brunchey earned 50 total points
ID: 1437785
There is a CommandBars property and you can test to see which ones are visible, once you find this out set the enabled property to false and go onto the next one.  A word of advice, store what the names of these toolbars are and set the enabled property back to true once it is done, or the next time the user tries to use word they cannot even see the menu bar for opening a file.  Here is some code....

Dim moWord As Word.Application
Dim i As Long
Dim llcmdbars As Long
Dim name_i  As Long
Dim lsCmdNames() As String


'create the instance of word
Set moWord = New Word.Application

'get the count of the commandbars
llcmdbars = moWord.CommandBars.Count

'loop through the commandbars checking the visible property
'if it is visible store it's name and then set the enabled 'property to false.  This will make it invisible.
For i = 1 To llcmdbars

     If moWord.CommandBars(i).Visible = True Then
        Debug.Print moWord.CommandBars(i).Name
        Debug.Print "***********"
        ReDim Preserve lsCmdNames(name_i)
        lsCmdNames(name_i) = moWord.CommandBars(i).Name
        name_i = name_i + 1
        moWord.CommandBars(i).Enabled = False
    End If
   
Next

'show word
moWord.Visible = True


'loop through the array of toolbar names that were visible and \
'reenable them.  If you don't do this the users version of word 'is pretty screwed up from here on out.
For i = 0 To name_i - 1
    moWord.CommandBars(lsCmdNames(i)).Enabled = True
    moWord.CommandBars(lsCmdNames(i)).Visible = True
Next i

'close word and destroy the object reference to it.
moWord.Quit
Set moWord = Nothing



0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now