×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

SW Design Table Update Problem.

SW Design Table Update Problem.

SW Design Table Update Problem.

(OP)
Hi Group,

I've written a VB6 application which among other things attempts(!) to update some info within design tables - it works sometimes, but the problem is getting the DT to be the active workbook. (there is another WB that must stay open in Excel while the program is running and sometimes it remains as the active WB, so when the program tries to modify the DT it targets the other WB and the DT is unchanged).  Code I use is as follows:

swbstat = swPart.Extension.SelectByID2("Design Table", "DESIGNTABLE", 0, 0, 0, False, 0, Nothing, swSelectOptionDefault)
swPart.InsertFamilyTableEdit
Set ExcelWB = ExcelApp.ActiveWorkbook

Any suggestions how upon opening the DT it can be forced to be the active WB?

Thx.

David G.

RE: SW Design Table Update Problem.

I am surprised that the table just opened is not the active workbook.  However, I do not access design tables in this manner (although I am curious if the table opens in a separate window or inside SolidWorks).  I use the following:

Set swDesignTable = swModel.GetDesignTable

swDesignTable.EditFeature

Another method you could try would be to get the name of the workbook that is always open and then cycle through all the open workbooks.  The one that does not match the known open workbook would then be the design table.

Regards,

Regg



RE: SW Design Table Update Problem.

(OP)
Thanks for your reply Regg - the cycle through thing seems to work.

Your open table method doesn't seem to work much differently than mine (although a bit sexier).

FYI DTs always open in Solidworks.

Cheers, David.

RE: SW Design Table Update Problem.

After thinking about it.  I believe it is a timing issue.  Design tables do not always open immediately.  The code simply gets ahead of the design table opening and finds the already open workbook.  I do not know how you re-wrote your code but my suggestion now (similar to my original) would be to get the current active workbook object, send your call to open the design table,then enter a do loop that checks for the active workbook change and exits when it happens.  The new active workbook is the design table.

Regards,

Regg

RE: SW Design Table Update Problem.

If you are interested in getting the DT to open in excel as opposed to in SW then you can use the following code...

Sub main()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager
swApp.SetUserPreferenceToggle SwConst.swUserPreferenceToggle_e.swEditDesignTableInSeparateWindow, True
boolstatus = Part.Extension.SelectByID2("Design Table", "DESIGNTABLE", 0, 0, 0, False, 0, Nothing, 0)
Part.InsertFamilyTableEdit
End Sub

RE: SW Design Table Update Problem.

neilc78,

I generally do not use the SelectByID calls because the people at SolidWorks API have led me to believe they are not that reliable (though it is funny that when you record a macro that this is the call that generally is recorded).  Thanks for the info about the user preference.

Regards,

Regg

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources