Type T????

J

James Cassidy

Ok,

I think I may have figured out how to add a slide to a presentation but one
last thing. When I do the folowing:

Dim part As T

The IDE basicaly says "Type 'T' is not defined" What do I need to do? Any
help would be greatly apreciated.

Thanks
 
S

Steve Rindsberg

James Cassidy said:
Ok,

I think I may have figured out how to add a slide to a presentation but one
last thing. When I do the folowing:

Dim part As T

The IDE basicaly says "Type 'T' is not defined" What do I need to do? Any
help would be greatly apreciated.

You don't say so but let's assume that you're automating PowerPoint since you
mention slides and presentations. What version?

And what are you automating it from? VBA within PPT, VBA from within another
Office app, or something else entirely?

In any case, what type do you expect T to be?
 
J

James Cassidy

I am automating Office 2007 products, in this case a PowerPoitn presentation.
I am using Visual Studio 2005 with the Open XML SDK 2.0.

I am trying to use:

'Insert the new slide and name it.
Dim newSlide As SlidePart
newSlide.AddPart(part, fileName)

Where AddPart(T,String)

The T is supposed to be the file part while the string is supposed to be the
id.

The documentation says:

Dim instance As OpenXmlPartContainer
Dim part As T
Dim id As String
Dim returnValue As T

returnValue = instance.AddPart(part, id)

But I am unable to declare the type T.

--
SSgt James J. Cassidy
Computer Systems Software Engineer USAF
DSN 276-1541 ext. 3512
Commercial 805-606-1541 ext. 3512
 
J

James Cassidy

This is my latest iteration of the code attempt, it is probably wrong but
with each iteration I learn a bit more. =-)

Public Function PPTInsertNewSlide(ByVal fileName As String, ByVal position
As Integer, ByVal title As String) As Boolean
Dim returnValue As Boolean = False
Dim documentPart As PackagePart = Nothing
Using pptPackage As Package = Package.Open(fileName, FileMode.Open,_
FileAccess.ReadWrite)
' Get the main document part (presentation.xml).
For Each relationship As PackageRelationship In _
pptPackage.GetRelationshipsByType(documentRelationshipType)
Dim documentUri As Uri = PackUriHelper.ResolvePartUri(New
Uri("/", _
UriKind.Relative), relationship.TargetUri)
documentPart = pptPackage.GetPart(documentUri)
Dim part As T
If documentUri <> Nothing Then
'Insert the new slide and name it.
Dim newSlide As SlidePart
newSlide.AddPart(part, fileName)
End If
' There is only one document.
Exit For
Next
End Using
Return returnValue
End Function
--
SSgt James J. Cassidy
Computer Systems Software Engineer USAF
DSN 276-1541 ext. 3512
Commercial 805-606-1541 ext. 3512
 
C

Chirag

Hi,

SlidePart.AddPart() takes in a layout part as its parameter. You need to
declare "part" as "SlideLayoutPart":

Dim part As SlideLayoutPart

Another thing in your code, you need to assign newSlide to something before
calling AddPart() method. At present, it is not assigned to anything after
you declare newSlide as SlidePart. Perhaps you want to add a new slide part
in a presentation part.

- Chirag

PowerShow - View multiple PowerPoint slide shows simultaneously
http://officeone.mvps.org/powershow/powershow.html
 
S

Steve Rindsberg

Ah, I see Chirag's replied to one of your other posts. He should be
able to narrow this down.
 
J

James Cassidy

Thank you for your patients and knowledge. Here is what I have so far:

Public Function PPTInsertNewSlide(ByVal fileName As String, ByVal position
As _
Integer, ByVal title As String) As Boolean
Dim returnValue As Boolean = False
Dim documentPart As PackagePart = Nothing
Using pptPackage As Package = Package.Open(fileName, FileMode.Open,_
FileAccess.ReadWrite)
' Get the main document part (presentation.xml).
For Each relationship As PackageRelationship In _
pptPackage.GetRelationshipsByType(documentRelationshipType)
Dim documentUri As Uri = PackUriHelper.ResolvePartUri(New
Uri("/",_
UriKind.Relative), relationship.TargetUri)
documentPart = pptPackage.GetPart(documentUri)
Dim part As SlideLayoutPart
If documentUri <> Nothing Then
'Insert the new slide and name it.
Dim newSlide As SlidePart
documentPart.CreateRelationship(newSlide.Uri,
TargetMode.Internal,_
slideRelationshipType)
newSlide.AddPart(part, fileName)
End If
' There is only one document.
Exit For
Next
End Using
Return returnValue
End Function

I am not sure what ti initialize the part and newSlide to. By the way is
there a good site or book I can get my hands on so that I can bug experts
like yourself less and maybe contirbute knoledge to others that need it?

Again thank you very much. =-)
--
SSgt James J. Cassidy
Computer Systems Software Engineer USAF
DSN 276-1541 ext. 3512
Commercial 805-606-1541 ext. 3512
 
J

James Cassidy

Thanks Chirag,

I will study those sites so that I can come back with better informed
questions. =-)
--
SSgt James J. Cassidy
Computer Systems Software Engineer USAF
DSN 276-1541 ext. 3512
Commercial 805-606-1541 ext. 3512
 

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