deepa22


Hi,

I am trying to load a macro to Powerpoint 2007. I have created a dll called HelpMe , in that dll , i create a custom menu command under tools Menu.The piece of code is

Public Function test(oAppl As Object)

Dim NewMenu As CommandBarControl
Set cWindowMenu = oAppl.CommandBars.FindControl(Id:=30007)

If cWindowMenu Is Nothing Then
MsgBox "Something wrong while loading"
Else
Set NewMenu = cWindowMenu.Controls.Add(Type:=msoControlButton, Before:=2, Temporary:=True)
NewMenu.Caption = "pepsi"

End If

End Function

this dll is being referred by my macro called dest.ppa(template) where i call this test function.When powerpoint is started after loading this macro,it gives me message "something wrong while loading" i.e cWindowMenu comes to be nothing.

If i write this line twice in my test function,

Set cWindowMenu = oAppl.CommandBars.FindControl(Id:=30007)

then my custom command is visible , and works fine.

Please explain the reason for this behaviour and suggest some workaround.

Many Thanks for any help