Juno Posted April 28, 2004 Share Posted April 28, 2004 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 Quote Link to comment
MullinRJ Posted April 28, 2004 Share Posted April 28, 2004 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] Quote Link to comment
MullinRJ Posted April 28, 2004 Share Posted April 28, 2004 You're welcome, Juno. One thing to note, when spreadsheets are placed in the drawing, the object type is 56 (Worksheet Image). It's a different beast from the Spreadsheet of type 18. Raymond Quote Link to comment
Juno Posted April 29, 2004 Author Share Posted April 29, 2004 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 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.