Solved

Mord97 and VB

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

786 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