Cancel
Showing results for 
Search instead for 
Did you mean: 

Shop Doc Multiple Excel versions

PLM World Member Creator PLM World Member Creator
PLM World Member Creator

Hello

 

Is it possible to set multiple versions of Excel in shopdoc_excel.tcl

 

We use Excel 2013 and 2016 and they have different install directory.

 

Now we using 

 

#---------------------------------------------------------
# Specify proper location of the application's executable.
#

#set ::execute_file {C:\\Program Files\\Microsoft Office 15\\root\\office15\EXCEL.EXE}
set ::execute_file {C:\\Program Files (x86)\\Microsoft Office\\root\Office16\\EXCEL.EXE}

 

but it will be fine if we can set it to automatically detect right directory

 

Thanks

 Tomaz

Production: NX11.0.2 MP01
9 REPLIES

Re: Shop Doc Multiple Excel versions

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

You can use file exists to check for the existance of a file or glob to list all files matching a pattern.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.1, FBM, MRL 3.1.7 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 11.4
Development: C (ITK), .NET, Tcl/Tk Testing: NX12.0 | AWC 3.4 Preparing: NX12.0

Employees of the customers, together we are strong Smiley Wink
How to Get the Most from Your Signature in the Community
NX Customization - Best Practice Guide

Re: Shop Doc Multiple Excel versions

PLM World Member Creator PLM World Member Creator
PLM World Member Creator

Thanks, I will try

Production: NX11.0.2 MP01

Re: Shop Doc Multiple Excel versions

PLM World Member Creator PLM World Member Creator
PLM World Member Creator

i try this

 


#---------------------------------------------------------
# Specify proper location of the application's executable.
#
if {file exist {C:\\Program Files\\Microsoft Office 15\\root\\office15\EXCEL.EXE}
set ::execute_file {C:\\Program Files\\Microsoft Office 15\\root\\office15\EXCEL.EXE}
else
set ::execute_file {C:\\Program Files (x86)\\Microsoft Office\\root\Office16\\EXCEL.EXE}}

 

but I get error message

 

&MACRO MESSAGE_TEXT File name: o:\ugnx1102\ip7\src\camsmom\no\ind\mom_tcl_definitions.c, line number: 1411
&MACRO MESSAGE_TEXT Error Message: TCL error returned when evaluating file X:\Unigraphics_SETUP\NX110custom\NX110library\CAMresource\shop_doc\excel_templates\shopdoc_template.tcl
&MACRO MESSAGE_TEXT Trace: syntax error in expression "file exist {C:\\Program Files\\Microsoft Office 15\\root\\of...": variable references
&MACRO MESSAGE_TEXT require preceding $
&MACRO MESSAGE_TEXT ("if" test expression)
&MACRO MESSAGE_TEXT while compiling
&MACRO MESSAGE_TEXT "if {file exist {C:\\Program File
&MACRO MESSAGE_TEXT s\\Microsoft Office 15\\root\\office15\EXCEL.EXE}
&MACRO MESSAGE_TEXT set ::execute_file {C:\\Program Files\\Microsoft
&MACRO MESSAGE_TEXT Office 15\\root\\..."
&MACRO MESSAGE_TEXT invoked from within
&MACRO MESSAGE_TEXT "if { $__display_output_ext_app && [string match "win
&MACRO MESSAGE_TEXT dows*" $::tcl_platform(platform)] } {
&MACRO MESSAGE_TEXT
&MACRO MESSAGE_TEXT #--------------------------------------------------------..
&MACRO MESSAGE_TEXT ."
&MACRO MESSAGE_TEXT (file "X:/Unigraphics_SETUP//NX110custom/NX110library/CAMresource/shop_doc/excel_templates/shopdoc_excel.tcl" line 33)
&MACRO MESSAGE_TEXT invoked from within
&MACRO MESSAGE_TEXT "source "[file dirname [info script]]/sh
&MACRO MESSAGE_TEXT opdoc_excel.tcl""
&MACRO MESSAGE_TEXT (file "X:\Unigraphics_SETUP\\NX110custom\NX110library\CAMresource\shop_doc\excel_t

 

Thanks

Production: NX11.0.2 MP01

Re: Shop Doc Multiple Excel versions

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

looks like a syntax error.

try...

if {[file exist "C:\\Program Files\\Microsoft Office 15\\root\\office15\EXCEL.EXE"]} {
      set ::execute_file {C:\\Program Files\\Microsoft Office 15\\root\\office15\EXCEL.EXE
} else {
     set ::execute_file {C:\\Program Files (x86)\\Microsoft Office\\root\Office16\\EXCEL.EXE}
}

Note in tcl the { MUST be on the same line as the other commands, you can't put them on separate lines

(and the "}" for the "else" has to be on the same line as the "else")

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP16/TC11.2
I'd rather be e-steamed than e-diseaseled


Re: Shop Doc Multiple Excel versions

PLM World Member Creator PLM World Member Creator
PLM World Member Creator

I try this and found that must be 

 

if {[file exist "C:\\Program Files\\Microsoft Office 15\\root\\office15\EXCEL.EXE"]} {
set ::execute_file {C:\\Program Files\\Microsoft Office 15\\root\\office15\EXCEL.EXE} - missing }
} else {
set ::execute_file {C:\\Program Files (x86)\\Microsoft Office\\root\Office16\\EXCEL.EXE}
}

 

and when I try output it with Excel 2016 works, but with Excel 2013 don't 

 

If I switch lines with Excel path then works with Excel2013, but with 2016 don't

 

Production: NX11.0.2 MP01

Re: Shop Doc Multiple Excel versions

Legend
Legend

there is a error in your script :

in Tcl "" don't substitute a variable or string when you write : 

if {[file exist "C:\\Program Files\\Microsoft Office 15\\root\\office15\EXCEL.EXE"]} {
set ::execute_file {C:\\Program Files\\Microsoft Office 15\\root\\office15\EXCEL.EXE}
} else {
set ::execute_file {C:\\Program Files (x86)\\Microsoft Office\\root\Office16\\EXCEL.EXE}
}

you must write :

file exist {C:\\Program Files\\Microsoft Office 15\\root\\office15\EXCEL.EXE}

and not 

file exist "C:\\Program Files\\Microsoft Office 15\\root\\office15\EXCEL.EXE"

Finally return 0

it's almost like I'm writing:

C:\Program Files\Microsoft Office 15\root\office15EXCEL.EXE 

you should write :

file exist "C:\\Program Files\\Microsoft Office 15\\root\\office15\\EXCEL.EXE"

it s a mistake from the beginning of your code , all paths in tcl should be written :

C:/Program Files/Microsoft Office 15/root/office15/EXCEL.EXE

Don't miss {} or "" if your path has spaces

Hope que ça help

@mkn
Production: NX11.0.2.7,VERICUT 7.3.3
Development: Tcl/Tk, Gnuplot
www.deshors-tiremold.com

Re: Shop Doc Multiple Excel versions

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

You must take special care about the escaping too, since there is a backslash missing too. In addition it can happen that snippets get corrupted, so you need to check what you copy for syntax errors before you use it.

Might be time to also think about taking a Tcl training.

This should be easier to use, since it avoids escaping and the block if all together.

set ::execute_file [file nativename "C:/Program Files (x86)/Microsoft Office/root/Office16/EXCEL.EXE"]
if { ! [file exists "$::execute_file"] } {
    set ::execute_file [file nativename "C:/Program Files/Microsoft Office 15/root/office15/EXCEL.EXE"]
}

The above uses the slash as the path separator, since Tcl uses the UNIX notation for paths.

It also sets the global variable to the native name of the path initially to avoid the ELSE clause.

Then it checks if the file does not exist ( exclamation point before the command ) and if true, sets the global variable to the native path of the other office release.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.1, FBM, MRL 3.1.7 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 11.4
Development: C (ITK), .NET, Tcl/Tk Testing: NX12.0 | AWC 3.4 Preparing: NX12.0

Employees of the customers, together we are strong Smiley Wink
How to Get the Most from Your Signature in the Community
NX Customization - Best Practice Guide

Re: Shop Doc Multiple Excel versions

PLM World Member Creator PLM World Member Creator
PLM World Member Creator

Thanks everyone. 

Now working great.

 

Stefan, do you maybe know where I can find some Tcl training

Production: NX11.0.2 MP01

Re: Shop Doc Multiple Excel versions

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

@Tomaz wrote:

Stefan, do you maybe know where I can find some Tcl training


Do you have any experience in any other software development language? As a start reading the Tcl documentation might help you figuring out the difference between the development language you know and Tcl.

Active State, the page I posted the links to the documentation, might have some tutorials, else the web might be full of them too. May be the official Tcl/Tk Wiki is a good start.

Or some books:

  • Tcl/Tk for dummies
  • Tcl/Tk for the absolute beginner
Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.1, FBM, MRL 3.1.7 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 11.4
Development: C (ITK), .NET, Tcl/Tk Testing: NX12.0 | AWC 3.4 Preparing: NX12.0

Employees of the customers, together we are strong Smiley Wink
How to Get the Most from Your Signature in the Community
NX Customization - Best Practice Guide

Learn online





Solution Information