Macros written in excel 2002 Do not run in excel 2003

M

mansoorm

Hi,

I've written some macros in excel 2002 to create a commandbar and some
command buttons.
Everything was OK while I was using excel 2002.
Excel 2003, displays errors that indicate some object libraries are
missing.(Microsoft office 10 object library)

How can I change the macros to run both in excel 2002 & 2003 ?


Here is one of my macros::

Sub SetButtonImage(myBtn As CommandBarButton, imfile As String,
Optional immask As String)
On Error GoTo HANDLE_ERROR
Dim picPicture As IPictureDisp
Dim picMask As IPictureDisp

Set picPicture = stdole.StdFunctions.LoadPicture(imfile)
myBtn.Picture = picPicture

If immask <> "" Then
Set picMask = stdole.StdFunctions.LoadPicture(immask)
myBtn.Mask = picMask
End If
NO_ERROR:
Exit Sub
HANDLE_ERROR:
MsgBox Err.Description
Resume NO_ERROR

End Sub



Any comment is appreciated
 
J

Jim Rech

In the VBE with this project active go to Tools, References and uncheck
Office 10 and check the Office 11 object library. This should happen
automatically; I don't know why it didn't for you.

--
Jim
| Hi,
|
| I've written some macros in excel 2002 to create a commandbar and some
| command buttons.
| Everything was OK while I was using excel 2002.
| Excel 2003, displays errors that indicate some object libraries are
| missing.(Microsoft office 10 object library)
|
| How can I change the macros to run both in excel 2002 & 2003 ?
|
|
| Here is one of my macros::
|
| Sub SetButtonImage(myBtn As CommandBarButton, imfile As String,
| Optional immask As String)
| On Error GoTo HANDLE_ERROR
| Dim picPicture As IPictureDisp
| Dim picMask As IPictureDisp
|
| Set picPicture = stdole.StdFunctions.LoadPicture(imfile)
| myBtn.Picture = picPicture
|
| If immask <> "" Then
| Set picMask = stdole.StdFunctions.LoadPicture(immask)
| myBtn.Mask = picMask
| End If
| NO_ERROR:
| Exit Sub
| HANDLE_ERROR:
| MsgBox Err.Description
| Resume NO_ERROR
|
| End Sub
|
|
|
| Any comment is appreciated
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top