Excel >> VBA+API refresh userForm

by Greg » Mon, 17 Jul 2006 21:16:53 GMT

Using Show with vbModeless parameter I can change chart which I try to
How can I refresh my userForm to show parameters current chart (e.i.
size). Of course, it is possible to use button which loads up the
settings for the currently selected shape and displays them. But I need
to do it automatically, without button. Maybe API can help to do it but
I didn't find out any examples.
Can you help me?


Excel >> VBA+API refresh userForm

by NickHK » Tue, 18 Jul 2006 12:52:01 GMT

You still need to activate the code from some event.
What is changing that you need to refresh ?
I don't understand the connection between your userForm and "the currently
selected shape".


Excel >> VBA+API refresh userForm

by Greg » Tue, 18 Jul 2006 14:27:32 GMT

NickHK napisal(a):

I need to refresh userForm because chart or series on chart is
For example, I need to show size "new" chart but I don't want to press
any button.

ModelessForm.zip ( http://www.oaltd.co.uk/Excel/SBXLPage.asp ) is almost
what I want to achieve but working with cells, not chart.


Excel >> VBA+API refresh userForm

by Leith Ross » Tue, 18 Jul 2006 14:45:45 GMT

Hello Greg,

At the appropriate point in your code add this line. Change USerForm1
to the name of your form.


You may see a little flicker when it refreshes the form.

Leith Ross

Leith Ross
Leith Ross's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=18465
View this thread: http://www.excelforum.com/showthread.php?threadid=562033

Excel >> VBA+API refresh userForm

by NickHK » Tue, 18 Jul 2006 14:58:48 GMT

How do you put your chart on the userform ?
If the data behind a chart changes, then the Worksheet_Change event fires.
This can be update trigger.



Similar Threads

1. MSForms UserForm Window Handle - Win32 API Call from VBA - Excel

2. MSForms UserForm Control Identifier - Win32 API Call from VBA

Many thanks Tom,

FindWindow("ThunderDFrame", vbNullString) works just great to return the 
window handle of the MSForms UserForm object. (As does GetActiveWindow() - 
xl2003, WinXP Pro).

However, I'm still having some trouble obtaining the control identifier of 
the relevant controls on that MSForms UserForm. (Maybe this might be what you 
meant by 'windowless controls'?). GetDlgCtrlID is simply another Win32 API 
function declared as follows:

Declare Function GetDlgCtrlID Lib "user32" (ByVal hWnd As Long) As Long

Where hWnd is the handle of the window (or control) for which you want the 
control identifier returned. Works perfectly on Access and Windows Forms.

Logically enough, passing the window handle of an MSForms UserForm to 
GetDlgCtrlID returns 0 (null) - it doesn't have a control identifier because 
it is not a 'control'.

So what I need to do (if it is even possible, or unless there is another way 
that you or one of the other gurus here can advise) is obtain the window 
handle of each control on the MSForms UserForm that I want to add 
context-sensitive help to so that I can pass that to GetDlgCtrlID and obtain 
the control identifier to pass to HtmlHelp. (Phew!). Do MSForms userform 
controls (ListBox, CommandButton etc.) also have class names (as for 

I'm continuing to search and poke around, but any further assistance or tips 
that you or anyone else here can provide *very* gratefully received.

Thanks again, Sean.

"Tom Ogilvy" wrote:

> the class name for the form is ThunderXFrame or ThunderDFrame depending on
> the version of Excel. So you can use findwindow with that.  The MSforms 2.0
> controls are windowless controls, so I don't know if your GetDlgCtrlID API
> function will work or not since I don't know anything about it.
> -- 
> Regards,
> Tom Ogilvy
> "Sean Connolly" <Sean_Connolly(SpamAway)@auna.com.(DoNotSpam)> wrote in
> message news: XXXX@XXXXX.COM ...
> > Hello,
> >
> > Is there anyone out there that can maybe help me with some code or the
> name
> > of the Win32 API function to obtain the window handle of an MSForms
> UserForm
> > and/or control on that form?
> >
> > Let me explain a bit further. I've created a large model/application
> > (xl2003, WinXP Pro) - works peachy. I've also created a compiled help file
> > with HTMLHelp (*.chm) - again, no problems. Declaring and then calling the
> > HTMLHelp API in hhctrl.ocx successfully links the compiled help topics to
> the
> > Excel application.
> >
> > All great so far, but I have also created context-sensitive popup text
> help
> > which used to work great in the 'good old days' of WinHelp (*.hlp) and
> Help
> > Workshop via the "What's This" button. Things are different now.
> >
> > What I can successfully do in Access is write code for the MouseUp event
> of
> > an Access Form control to call the HTMLHelp API function and pass the
> > relevant parameters required. I intercept the right mouse button click and
> > 'presto' my text popups appear perfectly. The kicker is that this relies
> on
> > passing the built-in .hWnd property of Access Forms to the HTMLHelp API
> > function. (I also make use of the GetDlgCtrlID API function to pass the
> > relevant Access Form control's identifier and context-sensitive help text
> to
> > the HTMLHelp API function call).
> >
> > Excel MSForms don't seem to have the same built-in .hWnd property
> available,
> > so I'm thinking that I need to make a call to another Win32 API function
> in
> > order to return the window handle of my MSForms UserForm in Excel. I've
> spent
> > the best part of a week searching and trying different functions and
> methods
> > to obtain and return a) the window handle of an MSForms UserForm and
> > subsequently by using GetDlgCtrlID; b) the UserForm control's identifier.
> >
> > Is this even possible? Does anyone out there know how. Extremely grateful
> > for any tips, assistance or suggestions that anyone can provide. Let me
> know
> > if more info is needed from me.
> >
> > Thanks and Regards, Sean.

3. Userform template/api - Excel

4. Extend Excel C API add-in for using RibbonX API

Hi All,
My first question is this possible?

Most examples I have seen show how to extend a COM addin to use the
ribbon API.
I have an Excel Add-in that uses the C API (it uses the xlw wrapper
that is available on sourceforge.net). This addin has its own seperate
menu, with a bunch of menu items, that are functions/wizards. This add-
in works fine in Excel 2007.

I would now like to extend my addin to now use the RibbonX API, so
that instead of using the menus, the users can click on the buttons.

I think the issue here is whether i can "tie in" the C API menu items
to the callbacks that must be called by the buttons on the ribbons.

What's the optimal way to design this?

Additional details:
My project is compiled in VS2003, but can easily be compiled in VS2005
as well. In addition, my addin, does interact with a dotNET component,
that has a COM interface. The addin uses the dotNET part to display
the wizards (it was just so much neater and easier to do in dotNET)
but still uses the Excel C API to interact with Excel.

Any responses will be greatly appreciated.

5. API GetTickCount and API for sound - Excel

6. Fonction API AnimateWindow dans VBA appliqu??Excel

Quelqu'un peut-il me dire prisent quel code utiliser pour me servir de
cette fonction API?
                J'ai cherch mais cela ne marche pas ou bien je n'ai pas

                                    D'avance merci,


7. XML API in VBA under Excel? - Excel

8. Controlling the windows taskbar from VBA (API example)

I found this code on another post and it works perfectly... however (see below)

Private Declare Function FindWindowEx& Lib "user32" Alias "FindWindowExA" _
 (ByVal hWnd1&, ByVal hWnd2&, ByVal lpsz1$, ByVal lpsz2$)
Private Declare Function ShowWindow& Lib "user32" (ByVal hwnd&, ByVal 

Sub TaskBar_Hide()
ShowWindow FindWindowEx(0, 0, "Shell_TrayWnd", vbNullString), 0
End Sub

Sub TaskBar_Show()
ShowWindow FindWindowEx(0, 0, "Shell_TrayWnd", vbNullString), 5
End Sub

This seems to be setting a visible flag for the task bar.  What I need is to 
activate/deactivate the minimize of the task bar.  (When you position the 
mouse on the top line of the task bar, you get a double-headed arrow.  when 
you click-drag down, it minimizes the task bar. This leaves a small line 
which is the top of the task bar that you can grab and drag up to un-minimize 
the task bar).

How do I access that feature from VBA (using API or not)

I need this so that when I set my spreadsheet to show fullscreen, the status 
bar gets hidden under the taskbar (becuse I want to leave it set "always on 
top")  I have found that manually minimizing then maximizing the taskbar 
forces the status bar to show (I.E. the spreadsheet's full screen becomes 
limited at the bottom to force both the taskbar and the (excel) statusbar to 
be both visible.)

Also Im curious what the & in the above "FindWindowEx&" API call code does.  
The code stops working when that character is removed.