Solved

Mord97 and VB

Posted on 1998-10-02
3
152 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
add text to end of existing text in file 16 69
TT Auto Dashboard 13 82
Help me. 3 45
Advice in Xamarin 21 52
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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

911 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

21 Experts available now in Live!

Get 1:1 Help Now