Powerpoint interaction
Hi,
I know that it is possible to publish to PPTs in Hyperview.
I want to do a similar thing in HyperMesh.
My process is:
- Take a screenshot in Hypermesh.
- Open a new Powerpoint presentation and put the picture from screenshot into it by using TCl.
I got some trouble in using TCL to start PowerPoint and modify an existed ppt file.
Below is the code I have tried but it doesn't work. It kept telling me that the path could not be found.
Could anyone please help me with this
package require twapi set ppt [::twapi::comobj PowerPoint.Application] $ppt DisplayAlerts [expr 0] set present [$ppt Presentations] $present Open 'D:/Presentation2.pptx'
Answers
-
Maybe try in your TCL script: after taking the images, create a VBScript to insert them into PPT? You can execute a VBScript from TCL.
0 -
Hi,
Altair Forum User said:Hi,
I know that it is possible to publish to PPTs in Hyperview.
I want to do a similar thing in HyperMesh.
My process is:
- Take a screenshot in Hypermesh.
- Open a new Powerpoint presentation and put the picture from screenshot into it by using TCl.
I got some trouble in using TCL to start PowerPoint and modify an existed ppt file.
Below is the code I have tried but it doesn't work. It kept telling me that the path could not be found.
Could anyone please help me with this
package require twapi set ppt [::twapi::comobj PowerPoint.Application] $ppt DisplayAlerts [expr 0] set present [$ppt Presentations] $present Open 'D:/Presentation2.pptx'
Are you sure it reported 'path not found'?
I see error 'PowerPoint Frame Window doest not exist'
before open a file, you must show the window:
https://docs.microsoft.com/en-us/office/vba/api/powerpoint.application
0 -
@Q.Nguyen-Dai Thank you for your suggestion, That means I have to learn more about VBA to write this scripts. not gonna be easy .
@tinh on my HM, they said that 'path not found'. I will try your method. Thanks for the advice
0 -
I tested, and it worked on my file
In your case, check file path first (I think not existing or wrong name)
0 -
The problem I got is kind of weird.
5 minutes ago, the code worked well. and then, few later, the error showed up again
I cannot understand at all
0 -
I am not sure. my tests are no problem.
Try again after close all POWERPOINT.EXE processes (some of them may be hidden, you can see them in task manager)
https://docs.microsoft.com/en-us/office/vba/api/powerpoint.application
Tcl:
package require twapi set ppt [::twapi::comobj PowerPoint.Application] $ppt DisplayAlerts 0 $ppt Visible 1 set present [$ppt Presentations] $present Open 'D:/Presentation2.pptx'
0 -
Hi,
PowerPoint can't identify the file path includeing slashes as separators.
Try:
$present Open [file nativename 'D:/Presentation2.pptx']
0 -
Altair Forum User said:
Hi,
PowerPoint can't identify the file path includeing slashes as separators.
Try:
$present Open [file nativename 'D:/Presentation2.pptx']
I thought so, but in my case it worked.
0 -
@akitoguc Thanks you so much for your suggestion. Actually, I found that it worked with slashes when open files but not for some other functions. I have been stuck for a long time with the code to insert pictures to PPTs. Thanks for your advice, it works now.
For the problem 'The system cannot find the file specified', I believe that is due to some issue with twapi package when the script could not successfully run. It backs to normal when I restart the machine.
Below is my code for anyone interested in. For now, I am aiming to control the size and position of the picture and possibly add some captions with it.
#get the directory# set dirname [file dirname [info script]] set template_dirname '$dirname/template.pptx' set ppts_dirname '$dirname/component_list_PPts.pptx' #handle the files# catch {file delete -force '$ppts_dirname'} file mkdir 'D:/temp_folder' file copy -force '$template_dirname' 'D:/temp_folder' file rename -force 'D:/temp_folder/template.pptx' 'D:/temp_folder/component_list_PPts.pptx' file copy -force '$template_dirname' 'D:/temp_folder' #modify the PPts# package require twapi set ppt [::twapi::comobj PowerPoint.Application] $ppt DisplayAlerts [expr 0] set presents [$ppt Presentations] $presents Open 'D:/temp_folder/component_list_PPts.pptx'; #Open the Presnetation set active_presentation [$ppt ActivePresentation]; #get the cureently active presentaatin set slides [$active_presentation Slides]; #gte the slide list set slide_1 [$slides Item 1]; #get control on slide index 1 set slide_2 [$slides InsertFromFile 'D:/temp_folder/template.pptx' 1]; #add one more slide into the presentation set slide_3 [$slides InsertFromFile 'D:/temp_folder/template.pptx' 1]; #add one more slide into the presentation set slide_1_shapes [$slide_1 Shapes] return set slide_1_picture [$slide_1_shapes AddPicture [file nativename 'D:/2.bmp'] -1 -1 5 4]
0 -
Does this package works on Linux?
0 -
Hi,
twapi is for windows and will not work in Linux
0 -
Altair Forum User said:
@akitoguc Thanks you so much for your suggestion. Actually, I found that it worked with slashes when open files but not for some other functions. I have been stuck for a long time with the code to insert pictures to PPTs. Thanks for your advice, it works now.
For the problem 'The system cannot find the file specified', I believe that is due to some issue with twapi package when the script could not successfully run. It backs to normal when I restart the machine.
Below is my code for anyone interested in. For now, I am aiming to control the size and position of the picture and possibly add some captions with it.
#get the directory# set dirname [file dirname [info script]] set template_dirname '$dirname/template.pptx' set ppts_dirname '$dirname/component_list_PPts.pptx' #handle the files# catch {file delete -force '$ppts_dirname'} file mkdir 'D:/temp_folder' file copy -force '$template_dirname' 'D:/temp_folder' file rename -force 'D:/temp_folder/template.pptx' 'D:/temp_folder/component_list_PPts.pptx' file copy -force '$template_dirname' 'D:/temp_folder' #modify the PPts# package require twapi set ppt [::twapi::comobj PowerPoint.Application] $ppt DisplayAlerts [expr 0] set presents [$ppt Presentations] $presents Open 'D:/temp_folder/component_list_PPts.pptx'; #Open the Presnetation set active_presentation [$ppt ActivePresentation]; #get the cureently active presentaatin set slides [$active_presentation Slides]; #gte the slide list set slide_1 [$slides Item 1]; #get control on slide index 1 set slide_2 [$slides InsertFromFile 'D:/temp_folder/template.pptx' 1]; #add one more slide into the presentation set slide_3 [$slides InsertFromFile 'D:/temp_folder/template.pptx' 1]; #add one more slide into the presentation set slide_1_shapes [$slide_1 Shapes] return set slide_1_picture [$slide_1_shapes AddPicture [file nativename 'D:/2.bmp'] -1 -1 5 4]
Hello @Toan Nguyen , Did you find a way to control the position ans size of picture, you imported to Powerpoint. I'm also working in the same thing, wherein I need to import screen captures from Hypermesh to PowerPoint. Any help is appreciated. TIA.
0 -
Hi @rrishav
Yes, I found the way to control the size and the position of the picture.
You can do that directly when you import the picture with 'AddPicture' command. below is what I have done in my code
set slide_picture [$slide_shapes AddPicture [file nativename '$picture_folder/comp_$comp.bmp'] -1 -1 80 40 800 400]
The last four numbers are used to control position (the distance to left and top of the slide) and the size (width and height) of the picture.
Give it a try and you will see
0