Jump to content

Worksheet Title formula for Data Tag?


Recommended Posts

Copy the single line below and paste it into a blank Vectorscript named WSNameToTag

WSScript_SetResStr(GetName(GetWSFromImage(WSScript_GetObject)));

 

Once you have the script created, edit your tag to include the following line:

 

#WS_RUNSCRIPT('WSNameToTag')#

 

All of the punctuation is critical. Just copy and paste and it should work.  The script will have to be included in every file that you want to use the Data Tag in.

 

HTH

  • Like 1
Link to comment
16 minutes ago, Pat Stanford said:

Copy the single line below and paste it into a blank Vectorscript named WSNameToTag

WSScript_SetResStr(GetName(GetWSFromImage(WSScript_GetObject)));

 

Once you have the script created, edit your tag to include the following line:

 

#WS_RUNSCRIPT('WSNameToTag')#

 

All of the punctuation is critical. Just copy and paste and it should work.  The script will have to be included in every file that you want to use the Data Tag in.

 

HTH

 

@Pat Stanford that is really cool but I am confused: is it still the case as per the thread below that you can't return the name of a worksheet in a spreadsheet cell, even though you can do it with a Data Tag + a database...?

Link to comment

Yes. The worksheet has no way of knowing what its name is.  In this case, since you can't Data Tag a worksheet, but only a Worksheet Image, I use that to our advantage.

 

I can get a handle to the worksheet from the worksheet image and then get the name of that worksheet.

 

The Data Tag just happens to be able to use the WSScript_GetObject and WSScript_SetRetStr functions to do the I/O and find out the tagged object.

  • Like 1
Link to comment

A Database SubRow (unless it is SUMmarized) and a Data Tag both return a reference to a single specific object.

 

In this case of the Data Tag, that reference is to a Worksheet Image. Once you have the handle to the Image you can get the Handle and then the name of  the parent Worksheet object.

 

In a Database subrow, since the objects returned (except for the special case below) are not Worksheet Images, there is no way for a script to know what environment it is running from. So a worksheet script can't say "I'm running inside of Worksheet XYZ" (actually it could, but it does not do that now). So since you can't get the handle to the worksheet, you can't get the name of the worksheet either.

 

The special case would be a worksheet which had a database row with a criteria of Object Type is Worksheet Image. In that case you could probably get the Worksheet name for each image.  And maybe you could do some trickery in the criteria to only return a single Worksheet Image that happened to be an image of the worksheet producing the image and be able to get the worksheet name. But as I was once told:

 

Quote

"What you are trying to do sounds fancy, and as such it sounds like it won't work.”

Vlado Stanev, VW SDK List Dec. 4, 2015

 

If you want to play be my guest.  Create a worksheet with a database row returning Worksheet Images and see what it would take to get the criteria set to only show a single image. You could then use a =RunScript('WSNameToTag') script from above to return the actual worksheet name from the resource manager.

 

I think the effort to define the criteria would be much harder than just typing in the name.  But maybe if you only had one worksheet on each layer and could use just a layer criteria it might work,

 

Good Luck.

Link to comment
8 hours ago, Pat Stanford said:

If you want to play be my guest.  Create a worksheet with a database row returning Worksheet Images and see what it would take to get the criteria set to only show a single image. You could then use a =RunScript('WSNameToTag') script from above to return the actual worksheet name from the resource manager.

 

Thanks yes I did this already + that's why I asked the question: you CAN return the name of a Worksheet resource using your formula in a database header cell but you CAN'T do the same in a spreadsheet cell, correct? It's an academic question. I always assumed (probably naively) that anything you did in a database you could also do in a spreadsheet cell, you just needed to include the relevant criteria, but I was wrong to think this as there is no way to include criteria in the RUNSCRIPT function right?

 

The question in the other thread was 'Is there a function I can put in a worksheet to display the worksheet name?' + the answer was no. But technically the answer was, 'Yes you can in a database but not in a spreadsheet cell' right? I'm not saying it's a practical approach, it is more that I am confused that you can do one thing in a database but can't do the same in a spreadsheet. But like I say this was probably naivety on my part + there are hundreds of other examples of the same.

Link to comment

There are a number of WS Functions that you can't pass criteria to in Spreadsheet cells.  RunScript and standard Record.Field are the two most obvious and ones that could be made more useful by having a way to pass criteria.  

 

And I think the ObjectData - 'Universal Value' kind of supports criteria for Record.Field but as we said in the other thread, it is currently hindered by not handling compound criteria.

 

Maybe Someday.

  • Like 1
Link to comment

OK, so like I considered earlier, I set up a data tag to grab the text from the name field in the OIP. It's a bit of work, but easy enough. I copy the title of the worksheet, type into the OIP Name field "WS: " and then paste the worksheet title text. Then I associate the data tag to the worksheet.

 

Screenshot2024-02-28at9_00_14PM.thumb.png.0c623b9a6ef5e9d7f85700166b3959a3.png

Edited by Bruce Kieffer
Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...