Can this be done ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can the background's colour of the Excel Formula Bar be set ?

Unlike other objects in the Excel object model, the formula bar exposes a
window handle and a Class name "EXCEL;" so I thought maybe changing its
background colour could probably be achieved via some API calls .(
SendMessage or....)

Any ideas on this would be much appreciated .

Jaafar.
 
KeepITCool,......Thanks for the links :)

I already know about the NameBox code but I wanted to see more ways of
manipulating Excel objects trhough the API as there isn't enough information
available on this subject .

I bought myself a couple of books on VB/API but they are not written in a
clear methodical manner and offer very few examples. They show you snippets
of code but never go deep enough into showing you how they actually work so
you can start applying what you learn to new scenarios. They are also VB
oriented NOT VBA.

This makes it very difficult for anyone wanting to expand their knowledge of
using APIs with VBA\MSO applications.

Any suggestions as to how I could best further my knowledge in this area
would be much appreciated .

Thanks.

Jaafar.
 
RAFAAJ2000 said:
Any suggestions as to how I could best further my knowledge in this area
would be much appreciated .

Thanks.

Jaafar.


Hi Jaafar

Dan Appleman
Visual Basic Programmer's Guide to the Win32 API
SAMS
ISBN 0-672-31590-4

is *the* "Bible".
 
Hi Rafaaj2000,
This makes it very difficult for anyone wanting to expand their knowledge of
using APIs with VBA\MSO applications.

Read chapter 9 of Professional Excel Development:
http://www.oaltd.co.uk/DLCount/DLCount.asp?file=ProExcelDev09.pdf

and see some of the other files on my site, many of which use API calls to
manipulate Excel.

Regards

Stephen Bullen
Microsoft MVP - Excel

Professional Excel Development
The most advanced Excel VBA book available
www.oaltd.co.uk/ProExcelDev
 
Hi Rafaaj2000,
Can the background's colour of the Excel Formula Bar be set ?

Unlike other objects in the Excel object model, the formula bar exposes a
window handle and a Class name "EXCEL;" so I thought maybe changing its
background colour could probably be achieved via some API calls .(
SendMessage or....)

Sure, something like:

hWnd = FindWindowEx(Application.hWnd,0,"EXCEL<",vbnullstring)
hDC = GetDC(hWnd)
SetBkColor hDC, &h0000FF
ReleaseDC hWnd,hDC

N.B. "EXCEL<" is the class name of the edit box bit of the formula bar.

Regards

Stephen Bullen
Microsoft MVP - Excel

Professional Excel Development
The most advanced Excel VBA book available
www.oaltd.co.uk/ProExcelDev
 
Thanks Stephen ,

Is the 'SetBKColor' a UDF ? if so, it is not defined in your code !
If it is an API Function why can't I find it on the API functions list ?!!

Thanks again.

Jaafar.
 
Ok, I found the SetBKColor function in the 'gdi32' Library and the code works
great apart from one problem :The colouring of the Formula bar is
inconsistent ie : it keeps coming and going .

Also, how do I set the Formula colour back to its default ?

Great stuff Stephen and thanks very much :)

Jaafar.
 
Hi Rafaaj2000,
Ok, I found the SetBKColor function in the 'gdi32' Library and the code works
great apart from one problem :The colouring of the Formula bar is
inconsistent ie : it keeps coming and going .

Yeah, I guess Excel is setting some colouring when you edit a formula
Also, how do I set the Formula colour back to its default ?

call it again, setting a backcolour of &HFFFFFF?

Regards

Stephen Bullen
Microsoft MVP - Excel

Professional Excel Development
The most advanced Excel VBA book available
www.oaltd.co.uk/ProExcelDev
 
Back
Top