Solved

Help with converting VB EXE to VB DLL - automating Powerpoint.

Posted on 2004-10-19
4
591 Views
Last Modified: 2012-05-05
Hi

I need create a DLL componenet which will be called by an ASP page. The ASP page will call/create the DLL component and pass a list of image names with path info(comma seperated). The DLL will automatically create a Powerpoint presentation and insert the images into it and save the presentation.

I have got the following bit of code working as an EXE app. It does not take any parameters in though. When I create a DLL in Visual Studio and use the same code it compiles but hangs on running.

I would very much appreciate if anyone can help me convert the code to work as DLL and show me how to pass the image names from ASP into VB DLL.

Thank you.

________________________________________________________

Sub InsertImage()

    Dim ppApp As PowerPoint.Application
    Dim ppPres As PowerPoint.Presentation
    Dim ppShape As PowerPoint.Shape
    Dim ppCurrentSlide As PowerPoint.Slide

    Set ppApp = CreateObject("PowerPoint.Application")
    ppApp.Visible = True
   
    Set ppPres = ppApp.Presentations.Add(msoTrue)
    Set ppCurrentSlide = ppPres.Slides.Add(Index:=1, Layout:=ppLayoutBlank)
    ppPres.ApplyTemplate ("C:\cfdeals.ppt")

    With ppCurrentSlide.Shapes
        ' Adds a picture to slide 1 in the active presentation.
        Set oPicture = .AddPicture("C:\image1.jpg", msoFalse, msoTrue, 92, 132, 1, 1)
        ' Now scale the image
        oPicture.ScaleHeight 1, msoTrue
        oPicture.ScaleWidth 1, msoTrue
       
    End With
    ppPres.SaveAs "C:\hello.ppt"
    ppApp.Quit
   
End Sub

_________________________________________________________
0
Comment
Question by:iam_david_lee
  • 2
  • 2
4 Comments
 
LVL 14

Accepted Solution

by:
aelatik earned 250 total points
ID: 12348346
You could try removing all references ( use late binding ) and translating the constants to their real values and try executing it directly from ASP.
This sample works from VBSCRIPT, it means it can also execute in ASP if you set the right permissions to the filesystem.

<%
    Dim ppApp, ppPres, ppShape, ppCurrentSlide

    Set ppApp = CreateObject("PowerPoint.Application")
    Set ppPres = ppApp.Presentations.Add(vbNull)
    Set ppCurrentSlide = ppPres.Slides.Add(1, 12)
        ppPres.ApplyTemplate ("C:\cfdeals.ppt")
    With ppCurrentSlide.Shapes
        Set oPicture = .AddPicture("C:\image1.jpg", vbNull, vbNull, 92, 132, 1, 1)
            oPicture.ScaleHeight 1, vbNull
            oPicture.ScaleWidth 1, vbNull
    End With
   
    ppPres.SaveAs "C:\hello.ppt"
    ppApp.Quit
%>
0
 

Author Comment

by:iam_david_lee
ID: 12360180
Hi

Thanks aelatik. I used your solution but I am getting the following error message.

Microsoft PowerPoint 2002 error '80004005'
Presentation.SaveAs : An error occurred while PowerPoint was saving the file.

I couldn't find much info on this error online....Any ideas....


Thankx.
0
 
LVL 14

Expert Comment

by:aelatik
ID: 12360259
Give the IUSR internet acount access to the folder you are trying to write in. I think its a security issue.
0
 

Author Comment

by:iam_david_lee
ID: 12379400
Thanks. Got it working now...

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now