I know probably the wrong place to post this, but I know from past experience with Excel VBA problems I have had that this site is one of the best for finding solutions. I actually posted to the Powerpoint forum first, but this isn't REALLY a powerpoint problem, it is more of a MS Project problem. I noticed that the posts in the powerpoint forum don't often get responses for weeks, so I am posting here. If someone out there has the ability to delete my powerpoint post so I am not cross-posting please help.
I am being asked to right code for MS Project this time. I have run into a number of circumstances where I can't get code to work in MS Project the way it does in Excel. But my latest one I can't make a work-around for. I am trying to add a shape that isn't just a straight text box into a powerpoint presentation using the "Set" command so that I can change formatting, text, etc after placing it. If I run this code using a VBA window that I have opened in Powerpoint it works fine, but if I do from MS Project, I get a "Run-Time error '13': Type Mismatch". Under "Tools --> Reference" I have made sure that all the things checked in Powerpoint are also checked in MS Project. I am at my wit's end. Please help. Even if to point me into a different place to post this question if I am in the wrong place. Thanks in advance.
Sub make_shape()
Dim objPPApp As Object
Dim objPresentation As Object
Dim objSlide As Object
Dim objSuc As Shape
Dim objBar As Object
Set objPPApp = CreateObject("PowerPoint.Application")
objPPApp.Visible = msoTrue
Set objPresentation = objPPApp.Presentations.Add
Set objSlide = objPresentation.Slides.Add(1, ppLayoutTitle)
' This works
Set objBar = objSlide.Shapes.AddShape(msoTextOrientationHorizontal, 100, 100, 100, 100)
' This works
objSlide.Shapes.AddShape Type:=msoShapeChevron, left:=50, top:=50, width:=50, height:=50
' This doesn't if run from MS Project, does work if run straight from macro within Powerpoint. Very frustrating. HELP!
Set objSuc = objSlide.Shapes.AddShape(msoShapeChevron, 50, 50, 50, 50)
End Sub
Bookmarks