Pasting an Icon in Notes Field of Task Throws runtime Error '485':. Variable Uses an Automation typ

P

Pradeep Mishra

Hi,

While Working with an add-in written for Microsoft Project 2000 SP-1,
i came across a strange behaviour of COM plug-in written for MSProject
in Visual Basic 6.0.

If i write code in ProjectBeforeTaskChange() event of MSProject then
Pasting an Icon(Just an Icon and nothing else) in Notes Field of a
task throws an runtime Error.

This can be reproduced through following steps.

1. Open Visual Basic, New Add-in Prject
2. Open Connect.dsr
3. Select Application "Microsoft Project"
4. Choose Application Version "Microsoft Project 9.0"
5. Initial Load Behavior "Startup"
6. open Code Window
7. Delete all Pre-Written code
8. Paste the following code in Connect.dsr
'--------------------------------------------------------------------
Option Explicit

Public WithEvents MSProjectApp As MSProject.Application

Private Sub AddinInstance_OnConnection(ByVal Application As
Object,ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode,
ByVal AddInInst As Object, custom() As Variant)

Set MSProjectApp = Application

End Sub

Private Sub MSProjectApp_ProjectBeforeTaskChange(ByVal tsk As
MSProject.Task, ByVal Field As MSProject.PjField, ByVal NewVal As
Variant, Cancel As Boolean)

MsgBox "Before Task Change"

End Sub
'--------------------------------------------------------------------


9. Compile the Code.

10. Open MSProject
11. Create a new project
12. Enter Task Name
13. Right click on a toolbar and Select Customize.
14. Right click on a button with image i.e. Save on main tool bar.
15. Press Copy Button Image
16. Close the customize box
17. Double click on task this will open Task Information Dialog.
18. goto last tab on the dialogbox which is named "Notes"
19 Rightclick on the Notes RTF Editor provided and press paste. Don'
type anything else.
20 Press OK Button.

Runtime Error occurs

Runtime Error '485':
Variable Uses an Automation type not supported in Visual Basic


Can any give a workaround so that this error does not occur.

Best Regards,
Pradeep Mishra
 
R

Rod Gill

Hi,

I suspect the declaration of the before change event is wrong.
MSProject.pjField

pjField is a constant, not a property of the Project object. This shouldn't
even compile and certainly shouldn't run. The field value is a long integer
I think.

--
For VBA posts, please use the public.project.developer group.
For any version of Project use public.project
For any version of Project Server use public. project.server

Rod Gill
Project MVP
For Microsoft Project companion projects, best practices and Project VBA
development services
visit www.projectlearning.com/
 
P

Pradeep Mishra

Hi, Thanks for replying.

This error is comming only on pasting an icon, and the visual basic
project i have created does have reference to Microsoft Project 9.0
type library. This event signature is untouched and is the default for
Task Change Event.
 

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