Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

After some trying I found a (workable) solution:

I check which change is being made using NameValueMap Context. In this case it is "ChangeSheetProperties".

private void OnChange(_Document DocumentObject, EventTimingEnum BeforeOrAfter, CommandTypesEnum ReasonsForChange, NameValueMap Context, out HandlingCodeEnum HandlingCode)
{
	UserInterfaceManager userInterfaceManager = Globals.invApp.UserInterfaceManager;
	Document document = Globals.invApp.ActiveDocument;
	DocumentTypeEnum documentType = document.DocumentType;
	DrawingDocument drawingDocument;
	Sheet sheet;

	if (BeforeOrAfter == EventTimingEnum.kBefore)
	{
		if (documentType == DocumentTypeEnum.kDrawingDocumentObject && Context.Item["InternalName"].ToString() == "ChangeSheetProperties")
		{
			drawingDocument = (DrawingDocument)document;
			sheet = drawingDocument.ActiveSheet;
			sheetSizeEnumOld = sheet.Size;
		}
	}

	if (BeforeOrAfter == EventTimingEnum.kAfter)
	{
		switch (documentType)
		{
			case DocumentTypeEnum.kDrawingDocumentObject:
				DrawingSheetSizeEnum sheetSizeEnum = sheet.Size;

				if (sheetSizeEnumOld != sheetSizeEnum && Context.Item["InternalName"].ToString() == "ChangeSheetProperties")
				{
					//DO SOMETHING
				}
				break;
		}

	}
	HandlingCode = HandlingCodeEnum.kEventNotHandled;
}

 

sheetSizeOld is declared at the constructor (it must have a value, cannot be null):

private DrawingSheetSizeEnum sheetSizeEnumOld = DrawingSheetSizeEnum.kADrawingSheetSize;

 

This solution will fire the OnDocumentChange twice: first the sheet sizes are different and my code is executed. That triggers again the OnDocumentChange event, but this time the sheet sizes are the same, so nothing further happens.

 

Still, I am interested how this could work using the HandlingCode. If anyone could me give an example (somewhere) on how to use this, would be great.