Solved

Mord97 and VB

Posted on 1998-10-02
3
156 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

717 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