Jump to content
Developer Wiki and Function Reference Links ×

Search criteria for worksheets


Juno

Recommended Posts

Hello.

The following line,

ForEachObject(GetHandle,T=SPRDSHEET);

does not seem to recognize the worksheets in my drawing, although other object types like RECT trigger the procedure. Is my object type name incorrect for worksheets? Is there a way to search by object type #, e.g. 18 for worksheets?

Thanks,

-juno

Link to comment

Hi Juno,

Your criteria doesn't work because Worksheets are not objects that are placed in the drawing. They hang off to the side, so to speak. If you need to get a handle to your Worksheets, try the following script. I modified it from one I wrote a while back to get handles to Saved Sheets.

You can call your procedure from inside the IF statement in the WHILE loop. The IF statement is necessary to filter out unwanted objects because there is more than one object type in the WS list.

HTH,

Raymond

code:

PROCEDURE WkSheets;

{ Raymond Mullin - 28 April 2004 }

{ Get a handle to each Worksheet in drawing and display name in Message window. }

CONST

WorksheetType = 18;

TmpWSName = 'WS Tmp';

VAR

WSHnd, hndDummyWS :Handle;

BEGIN

{ Get handle to a Dummy Sheet which gives you a handle in the Sheet list. }

NewSprdSheet(TmpWSName, 1, 1, 5, 3, False, False) ;

hndDummyWS := GetObject(TmpWSName); { Get handle to the new sheet }

WSHnd := PrevObj(hndDummyWS); { Get handle to previous object on List }

DelObject(hndDummyWS); { Not needed any more }

Message(''); Wait(1); { Clear Message Window, but leave open }

while (WSHnd <>nil) do begin { Traverse the WkSheet List }

if (GetType(WSHnd) = WorksheetType) then begin

Message(GetName(WSHnd));

Wait(1);

end; { if }

WSHnd := PrevObj(WSHnd); { Previous Obj on WkSheet List }

end; { while }

END;

Run(WkSheets);
[/code]

Link to comment

Thanks Raymond.

I am confused as to why the T=SPRDSHEET criteria exists at all unless it is treated differently for counting. I did notice that worksheets are "off to the side" as "objects", even when placed in the drawing. So much to learn...

Much obliged,

-juno

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...