J
jcherry7
I have python 3.0.1, and have downloaded pywin32 for python 3.x, aka build #213.
I ran win32com.client.makepy.py on Microsoft Office 12.0 Object Library and Microsoft PowerPoint 12.0 Object Library. The output files were placed in win32com.gen_py. I renamed them as MSO.py and MSPPT.py, respectively. The following code is located in my c:\Python30 folder. Thinkter is used to prompt the user to choose the image that they want to put onto the slide. THe 10 pointed star was an experiment, to try to import something into the image. Here is the code as I currently have it:
from tkinter import *
import tkinter.filedialog as tkFileDialog
import win32com.client # middleman/translator/messanger between windows and python
import win32com.gen_py.MSO as MSO # contains constants refering to Microsoft Office Objects
import win32com.gen_py.MSPPT as MSPPT # contains constants refering to Microsoft Office Power Point Objects
g = globals() # a dictonary of global vlaues, that will be the constants of the two previous imports
for c in dir(MSO.constants): g[c] = getattr(MSO.constants, c) # globally define these
for c in dir(MSPPT.constants): g[c] = getattr(MSPPT.constants, c)
Application = win32com.client.Dispatch("PowerPoint.Application")
Application.Visible = True # shows what's happening, not required, but helpful for now
Presentation = Application.Presentations.Add() # adds a new presentation
Slide1 = Presentation.Slides.Add(1, ppLayoutBlank) # new slide, at beginning
TenptStr = Slide1.Shapes.AddShape(msoShape10pointStar, 100, 100, 200, 200)
pictName = tkFileDialog.askopenfilename(title="Please Select the Image you wish to load")
print(pictName)
Pict1 = Slide1.Shapes.AddPicture(FileName=pictName, LinkToFile=False, SaveWithDocument=True, Left=100, Top=100, Width=200, Height=200)
this is the error:
Traceback (most recent call last):
File "C:\Python30\PowerPointEditer.py", line 21, in <module>
Pict1 = Slide1.Shapes.AddPicture(FileName=pictName, LinkToFile=False, SaveWithDocument=True, Left=100, Top=100, Width=200, Height=200)#pictName, pictName, 200, 200, 200, 200)
File "C:\Python30\lib\site-packages\win32com\gen_py\MSPPT.py", line 8544, in AddPicture
, Height)
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, "The specified file wasn't found.", None, 0, -2147024809), None)
It seems I'm passing AddPictures the wrong varibles
Thanks.
I ran win32com.client.makepy.py on Microsoft Office 12.0 Object Library and Microsoft PowerPoint 12.0 Object Library. The output files were placed in win32com.gen_py. I renamed them as MSO.py and MSPPT.py, respectively. The following code is located in my c:\Python30 folder. Thinkter is used to prompt the user to choose the image that they want to put onto the slide. THe 10 pointed star was an experiment, to try to import something into the image. Here is the code as I currently have it:
from tkinter import *
import tkinter.filedialog as tkFileDialog
import win32com.client # middleman/translator/messanger between windows and python
import win32com.gen_py.MSO as MSO # contains constants refering to Microsoft Office Objects
import win32com.gen_py.MSPPT as MSPPT # contains constants refering to Microsoft Office Power Point Objects
g = globals() # a dictonary of global vlaues, that will be the constants of the two previous imports
for c in dir(MSO.constants): g[c] = getattr(MSO.constants, c) # globally define these
for c in dir(MSPPT.constants): g[c] = getattr(MSPPT.constants, c)
Application = win32com.client.Dispatch("PowerPoint.Application")
Application.Visible = True # shows what's happening, not required, but helpful for now
Presentation = Application.Presentations.Add() # adds a new presentation
Slide1 = Presentation.Slides.Add(1, ppLayoutBlank) # new slide, at beginning
TenptStr = Slide1.Shapes.AddShape(msoShape10pointStar, 100, 100, 200, 200)
pictName = tkFileDialog.askopenfilename(title="Please Select the Image you wish to load")
print(pictName)
Pict1 = Slide1.Shapes.AddPicture(FileName=pictName, LinkToFile=False, SaveWithDocument=True, Left=100, Top=100, Width=200, Height=200)
this is the error:
Traceback (most recent call last):
File "C:\Python30\PowerPointEditer.py", line 21, in <module>
Pict1 = Slide1.Shapes.AddPicture(FileName=pictName, LinkToFile=False, SaveWithDocument=True, Left=100, Top=100, Width=200, Height=200)#pictName, pictName, 200, 200, 200, 200)
File "C:\Python30\lib\site-packages\win32com\gen_py\MSPPT.py", line 8544, in AddPicture
, Height)
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, "The specified file wasn't found.", None, 0, -2147024809), None)
It seems I'm passing AddPictures the wrong varibles
Thanks.