excel with project embeded in it

  • Thread starter Thread starter greg
  • Start date Start date
G

greg

Hello,
I have Excel with project embeded in it. (insert object>>ms project
document)
from excel vba i would like to talk to project.
so i am trying this

Dim x As Excel.Worksheet
Set x = ThisWorkbook.ActiveSheet
Set y = x.OLEObjects(1)
c = y.Tasks.Count

i would think that y is project. but it does not seem like it.

can anyone help?

thanks
 
Something like:

Dim x As Worksheet
Dim y As Object
Dim c As Integer
Set x = ThisWorkbook.ActiveSheet
Set y = x.OLEObjects(1)
y.Verb
c = ActiveProject.Tasks.Count
Debug.Print c
 
Hello,
Thank you for your response.
I get an "object required", when using this code:
c = ActiveProject.Tasks.Count
so I added this:
c = y.ActiveProject.Tasks.Count
and get this:
"object doesn't support this property or method"

I am using office 2003. does yours work?

thanks
 
Yes, it works for me in Excel 2003.

You should have a reference set to MS Project --
in the VBE, choose Tools>References, and add a check mark to
Microsoft Project 11.0 Object Library
 
Thanks for the help.
got it now

Dim x As Worksheet
Dim y As Object
Dim c As Integer
Set x = ThisWorkbook.ActiveSheet
Set y = x.OLEObjects(1)
y.Verb
c = y.Object.Tasks.Count
MsgBox "tasks - " + Str(c)
 
Back
Top