Jump to content
Sign in to follow this  
Suresh Vijayan

How to open already existing powepoint file using TCL

Recommended Posts

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

Share this post


Link to post
Share on other sites

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"

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...