Solved

Excel Design mode set/get via VB

Posted on 1998-10-28
6
362 Views
Last Modified: 2011-10-03
In Excel Visulal Basic Toolbar there is a Design button
(last one on the bar) to change the mode so that
any controls on the sheet becomes inactive/active.
I am looking for a way to do this switch from VBA or from
a VB (or VC++) client. This action can not be recorded
by macro recorder. And I am more interested to control this
from an outside client. thanks
0
Comment
Question by:has
[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
  • 3
6 Comments
 
LVL 3

Expert Comment

by:fguerreiro_inix
ID: 1442209
Try

Application.VBE.ActiveWindow.Type
or something around this...

Hope this helps
Regards
0
 

Author Comment

by:has
ID: 1442210
actually I tried that earlier.
Application.VBE.VBProjects(1).Mode is only for read, and
if used in VBA then it changes the mode automatically to run.
but even this, I can not do from an outside client. i.e
VARIANT i;
::VariantInit(&i);
i.vt = VT_I4;
i.lVal = 1;
VBIDE::VBEPtr pVBE = pApp->GetVBE();
VBIDE::_VBProjectsPtr pVBProjects = pVBE->GetVBProjects();// crashes right here, cant use pVBE for anything
VBIDE::_VBProjectPtr pVBProject = pVBProjects->Item(i);
if(VBIDE::vbext_vm_Run == pVBProject->GetMode())
MessageBox("run");
else if(VBIDE::vbext_vm_Break == pVBProject->GetMode())
MessageBox("break");
else if(VBIDE::vbext_vm_Design == pVBProject->GetMode())
MessageBox("design");

0
 
LVL 3

Accepted Solution

by:
fguerreiro_inix earned 100 total points
ID: 1442211
You can access the button like this.

For Each bar In Application.CommandBars
  If bar.Name = "Visual Basic" Then
    For ipos = 1 To CommandBars("Visual Basic").Controls.Count
      If CommandBars("Visual Basic").Controls(ipos).Caption = _
         "&Exit Design Mode" Then
            MsgBox "I have found the button"
      End If
    Next ipos
  End If
Next

You can also toogle the button and do all other things with it.

There are many possibilities ...
CommandBars("Visual Basic").Controls(ipos).Execute


Hope this helps
Regards
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:has
ID: 1442212
now I can run

Application.VBE.VBProjects(1).Mode  from my VC++ client
but this gives VBIDE::vbext_vm_Design mode (2) all times
even the mode is run (0). so vba gives 0 all times, outside
client gives 2 all times ??

Yes I may try to access the toolbar eventually, but there must be
a way of changing the mode from a client directly ????
0
 
LVL 3

Expert Comment

by:fguerreiro_inix
ID: 1442213
You could change the state of the button of the toolbar.

Bye
0
 

Author Comment

by:has
ID: 1442214
I go with the button state for now, thanks
0

Featured Post

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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 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…
Suggested Courses
Course of the Month9 days, 8 hours left to enroll

623 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