Cancel
Showing results for 
Search instead for 
Did you mean: 

VB macro with Excel: only for change dimensions?

Pioneer
Pioneer

Hi!

Can I use the Excel Visual Basic Macro for run vb code like a classic exe macro? (for example written with visual studio)

I think that with Excel I only change Variables, or not?

For example: Can I draw a View of a 3D model in a dft file, using an Excel VB macro?

 

Thanks

8 REPLIES 8

Re: VB macro with Excel: only for change dimensions?

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom
Hi Cek,
Yes you can.
Excel has build in VBA (Visual Basic for Applications). But this is an old version of VB.
You cannot use the nice new language features like in VS.
I do not like this combination of data and code in one file. If you make copies of the excel file and have the data then a change in the code becomes difficult. You have to do this in e dry copy...
Me recommendation is to write an extra program that uses the excel API to read the values and then changes the Solid Edge document.
regards

JB
SE 2019, VS2017

Re: VB macro with Excel: only for change dimensions?

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

Hi @Cek

 

Yes, As @JB has mentioned this is possible.

Everything that you can possibly do from Visual Studio standalone EXE can be done from Excel VBA also.

The lanuage to be used is old-fashioned VB but it is powerful as well for moderate purposes.

 

Personally I have a liking for using Excel for some types of Solid Edge automation tasks typically which take tabular data as input. These can be formatted nicely and also sorted, etc.

 

Regards,

~Tushar Suradkar

fb.pngSolid Edge Users Facebook Group

[ Everything under the sun about - Solid Edge ]

Re: VB macro with Excel: only for change dimensions?

Pioneer
Pioneer
Thanks!
I'm not expert in programming.
I try to write some code in Excel, with some example that I find on internet, but I don't know how change code from new vb to old vb.
Can you send some examples to connect with solid edge in vb?
or suggest a guide?
thanks!

Re: VB macro with Excel: only for change dimensions?

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Hi,

here is a small example:

  Dim objApp As Object
  Dim oDoc As SolidEdgePart.PartDocument
      
    Set objApp = GetObject(, "SolidEdge.application")
    
    Set oDoc = objApp.ActiveDocument
regards

JB
SE 2019, VS2017

Re: VB macro with Excel: only for change dimensions?

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

Hi @Cek

 

 

 

there is a wonderful example available directly witihn the customs folder of Solid Edge

 

Take a look into the "bearing

.

This shows the connection from an Excel table to a Solid Edge Part

 

20170501_1117.PNG

regards
Wolfgang

Re: VB macro with Excel: only for change dimensions?

Pioneer
Pioneer

Hello,

 

I was wondering if there was a way to edit/delete the links in the formula column of the variable table using a macro. Thank you

Re: VB macro with Excel: only for change dimensions?

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

Hello @mf2

 

Try

 

oVars.Edit("ShaftDiameter", "@'F:\Solid_Edge_Tutorials\Sample.xls'!'Sheet1!R11C7'")

 

Where,

oVars is the variable for the variables collection.

"ShaftDiameter" is the variable name in the variable table.

the other argument is the formula with complete path name with value in Row no. 11 and column G i.e. column number 7

 

Refer the tutorial:

Automation - Parametric Parts

 

For deletion, I think it could be simply set to an empty string, but I haven't tried it.

  

Hope this helps.

 

Tushar Suradkar

www.SurfAndCode.IN

 

Re: VB macro with Excel: only for change dimensions?

Valued Contributor
Valued Contributor

Yes, This is the nice example, that I found when I started learning.

 

regards

V.Sudheer