cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Getting the 'Untitled:1' filename?

PhilipOakley
5-Regular Member

Getting the 'Untitled:1' filename?

A while ago there was a Save Radio button
function.

Embedded in it was a short routine to give the
radio buttons a unique ID that depended on the
file name and file size.

Unfortunately, this cannot be added into a
template without error messages (because there is
no file name yet when a template is loaded..)

Is there a way of getting the magic "Untitled:1"
window title to use in absentia, in particular to
find out the sequence number part, so that each
newly opened blank file (with this as a utility)
can open with unique radio button IDs.

Obviously the VBscript would be slightly updated,
but it is quite simple once the problem has been
located.

Philip Oakley

PS Merry Christmas to all. Just having a rest from
the festivities.
6 REPLIES 6

On 12/25/2009 4:28:46 PM, philipoakley wrote:

>Unfortunately, this cannot be
>added into a
>template without error
>messages (because there is
>no file name yet when a
>template is loaded..)

So, you have an error, could be an 'on error goto' statement handle this? vbscript's On Error have not the full usual syntax than others basic languages. If there are an error you can trap this writing:

On Error Resume Next ' disable err stopping
-Instructions which can generate an error-
On Error GoTo 0 ' enable err stopping
if Err.Number = nn then -handle the error-

You can find the err number with a debugging message box like:

MsgBox ("Error n� " & CStr(Err.Number) & " " & Err.Description)

Well, I say: hope that this method works.

>Is there a way of getting the
>magic "Untitled:1" ...

If you use an instruction that need the name of the ws and because the ws is not saved you see an error "in your face" then can assume that when this happen you are using an "Untitled" new file.

To search if it is :1 or :2 or :n probably need another err handling, but have not idea if this can be done by this method.

Merry Christmas.

Alvaro.

On 12/25/2009 4:28:46 PM, philipoakley wrote:
>A while ago there was a Save
>Radio button
>function.
>
>Embedded in it was a short
>routine to give the
>radio buttons a unique ID that
>depended on the
>file name and file size.
>
>Unfortunately, this cannot be
>added into a
>template without error
>messages (because there is
>no file name yet when a
>template is loaded..)

That never even occurred to me!

>Is there a way of getting the
>magic "Untitled:1"
>window title to use in
>absentia, in particular to
>find out the sequence number
>part, so that each
>newly opened blank file (with
>this as a utility)
>can open with unique radio
>button IDs.

Yes. The attached worksheet contains a new version that fixes the problem.

Richard
RichardJ
19-Tanzanite
(To:RichardJ)

There was still a problem with that version, because if you load it from the Collab it can't find the file on your drive and gives an error. This version will work regardless of why the file does not exist.

Incidentally, the problem this script was written to fix (i.e. buttons in different worksheets interacting with each other in version 11) is fixed in version 14. I'm not sure when it was fixed though, because I couldn't be bothered to check versions 12 or 13.

Richard
PhilipOakley
5-Regular Member
(To:RichardJ)

Richard,
Ta for that I'll add it to my Normal.mct /
Normal.xmct files and test it out.


Philip Oakley

On 12/28/2009 5:50:11 PM, philipoakley wrote:
>Richard,
>Ta for that

Don't thank me too soon. I just thought of another problem. Actually, I'm surprised this never occurred to me before. Because of the way the GroupID is set programatically you can't have two groups of buttons in a worksheet. They will always have the same GroupID. I can't see any good way to fix this problem. I could add an input, and the user then has to specify a group identifier. If I do that though, the user might as well just set the GroupID manually. If they just choose a large random integer as the GroupID there is almost no chance of worksheet-worksheet interaction anyway.

Richard
PhilipOakley
5-Regular Member
(To:RichardJ)

Subtle red herring.. The very original problem was
that group IDs applied to all open sheets, hence the
script that depended on file name.

I see no problem in getting the user to provide the
local ID, so that they can have group 1, and group
2, open in two different worksheets. I would even
suggest that the ID should preferably be a string
(making any unhidden IDs feel sensible).

There is still the problem of having two blank
worksheets open, both of which are based on the
template with the code, which now have identical
group IDs - but we are working on that...
I'm thinking that OnLoad, one counts the number of
open files from the worksheet collection as one
approach.

Philip Oakley
Top Tags