Solved

Excel Design mode set/get via VB

Posted on 1998-10-28
6
359 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
Technology Partners: 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Paint/Redraw window while dragging 16 86
to transfer string from C lanaguage to VBA 4 77
VB6 - Convert HH:MM into Decimal 8 70
adding "ungroup sheets" to existing vbs code 5 56
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
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…
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…

749 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