Solved

Excel Design mode set/get via VB

Posted on 1998-10-28
6
353 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
  • 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
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.

 

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

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

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…
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…
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…

863 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

27 Experts available now in Live!

Get 1:1 Help Now