Powerpoint insertfromfile

N

NigelGomm

Hi,

i'm getting an error whenever i try and .insertfromfile with an (active
presentation) index > 327.

It tells me

OLE IDispatch exception code 0 from Microsoft Office PowerPoint 2003:
Slides.InsertFromFile : Integer out of range. 1 is not in SlideStart's valid
range of 1 to 0...

but the ppt file i'm inserting definitely has a slide 1. Tried with many
different ppt files and always the same error at index 328


Is it me or PowerPoint?


TIA

Nigel
 
P

Peter Huang [MSFT]

Hi

I think you may try to call the method from the VBA first to isolate the
problem
Sub Test()
ActivePresentation.Slides.InsertFromFile _
"D:\Test.ppt", 2, 3, 6
End Sub

The call above will insert the 3rd to 6th slides in the Test.ppt into
current ppt after 2nd PPT.

InsertFromFile Method
See AlsoApplies ToExampleSpecificsInserts slides from a file into a
presentation, at the specified location. Returns an integer that represents
the number of slides inserted.

expression.InsertFromFile(FileName, Index, SlideStart, SlideEnd)
expression Required. An expression that returns a Slides collection.

FileName Required String. The name of the file that contains the slides
you want to insert.

Index Required Long. The index number of the Slide object in the
specified Slides collection you want to insert the new slides after.

SlideStart Optional Long. The index number of the first Slide object in
the Slides collection in the file denoted by FileName.

SlideEnd Optional Long. The index number of the last Slide object in the
Slides collection in the file denoted by FileName.

Example
This example inserts slides three through six from C:\Ppt\Sales.ppt after
slide two in the active presentation.

ActivePresentation.Slides.InsertFromFile _
"c:\ppt\sales.ppt", 2, 3, 6



You may have a try and let me know the result.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Steve Rindsberg

Hi Nigel,

I can't replicate from VBA within PPT using:

Call ActivePresentation.Slides.InsertFromFile("name.ppt", _
ActivePresentation.Slides.Count)

Or

Call ActivePresentation.Slides.InsertFromFile("name.ppt", 1)

Started with 326 slides in the file and got bored with abusing it at 338 or so.

Tried again, this time supplying params for SlideStart, SlideEnd (1 in both
cases) and still no problems.

Have you applied SP1 to PPT?
 
N

NigelGomm

well it's a strange one.


most of the time the .insertfromfile works just fine. But i was getting that
error inserting the 328th slide. All previous 327 had been inserted ok. When
i manually opened up the presentation i was able to insert more slides no
problem.

I changed my code to use .count as the index instead of my own counter and
the problem seems to have gone away (which i cannot explain because the two
values are the same).

arrgh!

Nigel
 
S

Steve Rindsberg

well it's a strange one.

It's PowerPoint. Does the term "tautology" ring any bells? ;-)
I changed my code to use .count as the index instead of my own counter and
the problem seems to have gone away (which i cannot explain because the two
values are the same).

arrgh!

Entirely too bizarre for words. But if it works, let's not jostle it.
 
P

Peter Huang [MSFT]

Hi Nigel,

If you still have any concern on this issue, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
N

NigelGomm

the problem seems to have gone away for now, thanks Peter.

just one question : is there a maximum number of slides that can be in a
presentation ?

I'm getting more funny things happening at 3767 slides.

n
 
P

Peter Huang [MSFT]

Hi

In theory, there is no such limitation.
While due the computer's nature, it may vary due to the memory, harddisk,
filesystem ....
e.g.
Every slide has a unique id, which is of type long. The Long DataType in
x86 PC architecture is 32 bit(4 bytes).

SlideID Property
See AlsoApplies ToExampleSpecificsReturns a unique ID number for the
specified slide. Read-only Long.


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
N

NigelGomm

<grin>

and thanks for the sample code... it was that that gave me the idea to use
..count instead of keeping my own counter.

n
 
S

Steve Rindsberg

<grin>

and thanks for the sample code... it was that that gave me the idea to use
..count instead of keeping my own counter.

My pleasure. I figure it was probably one of my emails that set this off in
the first place (and I owe you some time to get the update and play some more,
but I've been swamped).
 

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