break variable link to excel

 

I want to programmatically break all links between Variables and Excel.  Inteactively, this is the process:

Tools - variables - variables (opens the Variable Table)

right click (any field of any variable) - Edit Links (opens the Links dialog)

hightlight the Excel source file - click Break Link - Click Yes

But I cannot figure how to do this programmatically.

I can get at the linked variables this way:

    Set ObjDoc = seApp.Documents.Open(FileName)

    Set Vars = ObjDoc.Variables         'variable object

    Set VarList = Vars.Query("*")       'list of all variables

    For Each xV In VarList

        temp = UCase(xV.Formula)

        If InStr(1, temp, ".XLS") Then bFoundXL = True: xV.Formula = ""   'Note: setting Formula="" does not break the link!

    Next xV

But this leave me stuck with the Excel file still referenced, even though it does not appear in any formulas.

So far I have tried:

1. Setting the formula to blank.  Problem is the link remains in place, as seen in Tools-PropertyManager.  If the referenced file is lost(broken), opening the file takes extra long.

2. ReduceFile method referenced in SESmiley Tonguerogramming with Solid Edge.  Problem is the method does not seem to actually exist.

3. BreakLinks method.  Cant figure out how to apply this to a variable linked to Excel.

Is there different way to go about this?

Platform: SE version 20, VB6

 

Posted by: Jon Zaerr
Post date: 5/13/2010 9:28:30 AM

4 REPLIES

RE: break variable link to excel

Have you tried to set the formula="value in mm or deg"

You should read the value of the variable. Be careful because distance values are in meters and angle values are in radians.

Then try to convert the value into the correct units (mm, in, or whatever) and write that into the formula as a string.

I would say i did that in the past and worked but i can't find the example.

Regards,

Julian

 

Posted by: Julian Guillo
Post date: 5/14/2010 5:13:11 AM

RE: break variable link to excel

Hi Bizare,

 

I've done it once by just editing the variables.

 

I had a variabletable with a lot of Excel Links. Via Variables.edit (name,value) I gave all the variables a new value, and the links where automatically broken. As you mention in your post you try to set the formula to "". Just edit the variable with the value it already has.

 

Good luck.

 

Posted by: Wouter Sloof
Post date: 5/16/2010 7:42:10 PM

RE: break variable link to excel

 

Thanks for the advice.  I tried this:

Set seApp = GetObject(, "SolidEdge.Application")

Set ObjDoc = seApp.activedocument

Set Vars = ObjDoc.Variables

call vars.edit("zzz","")

... But it had the same effect as:

.formula=""

... namely, the excel file is still linked, even though no variables reference it.

Strangely, both methods DO work with some files, i.e. break the link.

As an interim fix, I plowed through 180 files in a semi-automated fasion breaking the links with mouse clicks.  Ugly, but effective.  Also wearing on the index finger.

 

 

Posted by: Jon Zaerr
Post date: 5/25/2010 2:43:13 PM

RE: break variable link to excel

I can't find "Break Link" anywhere. Please help.

 

 

Posted by: Terry Tyson
Post date: 10/27/2010 8:44:13 AM