Convert Pptx to Jpeg

Hi,

i want to convert pptx to jpeg i have just one slide page ın pptx how can ı do this?

Dim pptapplication As New Microsoft.Office.Interop.PowerPoint.Application
Dim prsPres As Microsoft.Office.Interop.PowerPoint.Presentation = pptapplication.Presentations.Open(“PPT File Path”)
prsPres.Slides(1).Export(“Jpg File Path”, “jpg”, 0, 0)
prsPres.Close()
pptapplication.Quit()
For Each prog As Process In Process.GetProcesses
If prog.ProcessName = “POWERPNT” Then
prog.Kill()
End If
Next ı tried but not worked there are errors

Thnk u

@sedayngl_sedayngl33,

Try this code:

Dim pptApplication As New Microsoft.Office.Interop.PowerPoint.Application
Dim prsPres As Microsoft.Office.Interop.PowerPoint.Presentation = pptApplication.Presentations.Open("C:\path\to\your\presentation.pptx")
prsPres.Slides(1).Export("C:\path\to\output\image.jpg", "jpg")
prsPres.Close()
pptApplication.Quit()

' Ensure all PowerPoint processes are killed
For Each prog As Process In Process.GetProcessesByName("POWERPNT")
    prog.Kill()
Next

Points to remember:

  1. Ensure that the Office Interop assemblies are properly referenced.
  2. Ensure necessary permissions to access and manipulate the file paths specified.
  3. Confirm that the PowerPoint file does exist at the specified location.

Even after trying this if not working, please share the error details.

Thank you ,which package should be installed?

@sedayngl_sedayngl33,

No package as such required. Just make sure Microsoft Office installed on the machine which will fulfil this requirement: Office Interop assemblies


there was an error how can i solve this?

Thank You.

@sedayngl_sedayngl33,

Looks like script is quickly closing and quitting the PowerPoint after starting to export.

Can you try adding this code to give some time to script to export before it kills PowerPoint object Sleep(5000)

Updated code:

Dim pptApplication As New Microsoft.Office.Interop.PowerPoint.Application
Dim prsPres As Microsoft.Office.Interop.PowerPoint.Presentation = pptApplication.Presentations.Open("C:\path\to\your\presentation.pptx")
prsPres.Slides(1).Export("C:\path\to\output\image.jpg", "jpg")
Sleep(5000)
prsPres.Close()
pptApplication.Quit()

' Ensure all PowerPoint processes are killed
For Each prog As Process In Process.GetProcessesByName("POWERPNT")
    prog.Kill()
Next

You can increase or decrease the sleep time as per your observation. If it still fails, try increasing it to 10000 which will be 10 seconds.

2 Likes

Hello @sedayngl_sedayngl33

A less elegant way, but perhaps more easily read and implemented, is to simply use a Keyboard Shortcuts activity to press F12 and trigger the Save As-window inside PowerPoint.
Then use a Select Item activity to select the desired file type (.jpg).

After this you can fill out the desired file path and save the file as wanted.

Regards
Soren

Thank u for your support but not worked :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.