Pat Stanford Posted August 24, 2022 Share Posted August 24, 2022 Hello External Brain, Did we every talk about or solve the problem of having a worksheet script get a handle to the worksheet it is in? I need this for something I am working on. Basically I want a worksheet script to create a viewport of the worksheet the script is running in. So I need to get a handle to the worksheet so I can create a new Layer with an image of the worksheet on it to display in the viewport. I am hoping that I can make it work so that if multiple worksheets all have the script installed, they will all operate independently when you run the Recalculate All command. Any ideas or remembrances? Quote Link to comment
Vectorworks, Inc Employee Julian_Carr Posted August 24, 2022 Vectorworks, Inc Employee Share Posted August 24, 2022 I think the only way you could do this would be by hard wiring the worksheet name as a variable in the DATABASEBYSCRIPT() call. Then you could use GetObject() to obtain the handle. Quote Link to comment
MullinRJ Posted August 25, 2022 Share Posted August 25, 2022 Hey Pat, Not for nuthin', ActSSheet() still returns a handle to the open Worksheet. I don't know how long it will remain active as it was deprecated in VW 9.0, but it still compiles in VW 2022. You can test with: Message(GetName(ActSSheet)); Raymond Quote Link to comment
Pat Stanford Posted August 25, 2022 Author Share Posted August 25, 2022 Thank you both. I will see what I can make work. Both are reasonable ideas. Quote Link to comment
Pat Stanford Posted August 25, 2022 Author Share Posted August 25, 2022 Raymond, ActSSpread seems to be the same as GetTopVisibleWS. It returns the one at the top of the list regardless of which one is recalculating. I can probably make hard coding the name work, but it doesn't feel elegant. And I want to be elegant today. 😉 Quote Link to comment
MullinRJ Posted August 25, 2022 Share Posted August 25, 2022 Pat, is it too inelegant to place the WS name into a pre-defined cell and query that when your script runs? Raymond Quote Link to comment
Pat Stanford Posted August 25, 2022 Author Share Posted August 25, 2022 HI Raymond, Yeah Something like that is elegant enough. But unless you know a way to get the worksheet name into a worksheet cell by a formula, it is just as easy to have the name typed in as part of the WSScript parameter string formula. Thanks for the help. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.