How to open already existing powepoint file using TCL

Altair Forum User
Altair Forum User
Altair Employee
edited October 2020 in Community Q&A

Hi , 

 

how to open a already existing powerpoint file using exec command.

 

i tired  exec 'C:/Program Files (x86)/Microsoft Office/Office14/POWERPNT.EXE' 'C:\VSURES33\ppt_documents\CAE.pptx.

 

its working.

 

but i need i will use the command in any system i should not bother about office14 or office10 etc.

 

beacuse each user will different office system so it should support for that.

 

thanks in advance

 

suresh vijayan

Answers

  • tinh
    tinh Altair Community Member
    edited July 2017

    Hi, you are asking about defaul shell execution that you have to retrieve from window registry

    like this:

     

     proc shellopenfile {filepath} {     package require registry     set fileext [file extension $filepath]     if {[catch {         #below is sample code in manual         set type [registry get HKEY_CLASSES_ROOT\\$fileext {}]         set path HKEY_CLASSES_ROOT\\$type\\Shell\\Open\\command         set command [registry get $path {}]     }]} {         return -code error 'Not found default program to open file $fileext'     }     #we can open file by command, but it's better to make a batch     #because handle space in file path is so tough!     set fpt [open temp.bat w]     fconfigure $fpt -encoding utf-8     if {[string match '* %1' $command]||[string match '* \'%1\'' $command]} {         set command [string range $command 0 [string last ' ' $command]]     }     append command ' \'[file nativename $filepath]\''     puts $fpt $command     close $fpt     #now call the batch:     exec temp.bat &     set command }

     

    Now try open your file (remember to use / instead of \ , or use \\)

    shellopenfile 'C:/VSURES33/ppt_documents/CAE.pptx'