Solved

Mord97 and VB

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

726 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