Problem accessing BaseCalendars object

B

BC

I have a Dot Net 2.0 project that creates an instance of MS project through
Interop.

What I am trying to do is create a small function that will return a
calendar object, (just one of the default calendars for now.)

What I don't understand is this: According to the documentation (MS Office
Project 2003 SDK), you should be able to access a calendar in this collection
by either number or name. However it appears that any attempt to access a
calendar by number (or even the number represented as a string) causes a
crash. Even if I code the number literally it crashes. Getting to a
calendar object using the name works, but it might be more convenient for me
to use a number. (Admittedly I do not have that much experience working
with the Project Interop.)

As a test I wrote this bit of code, so I know the calendars and their
indices are there. Suggestions?

Dim C As MSProject.Calendar
For Each C In oMainProj.BaseCalendars
MsgBox(C.Name + ", " + C.Index.ToString)
Try
MsgBox(oMainProj.BaseCalendars.Item(C.Index).Name)
Catch ex As Exception
MsgBox(ex.Message)
End Try
Next
 

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