Showing posts with label com. Show all posts
Showing posts with label com. Show all posts

Tuesday, March 20, 2012

COMVariant type to work with Excel in AX

To avoid eventual issues while working with Excel objects in X++, do not forget about COMVariant type in AX!

Lets say we output some information directly to an Excel file and want to change the current row height based on the number of strings on notes.


...
COM             rng;
COMVariant      rowHeightVariant;
real            rowHeight;
...

rng = wks.Range(strFmt("A%1", curRow));   cell.Value2(_route.OprNum);
// to keep the current row height
rowHeightVariant = rng.RowHeight();
rowHeight = rowHeightVariant.double();
...
//to adjust the row height accordingly to the number of strings in notes
rng.RowHeight(rowHeight*this.countLines(notes));
...


Unfortunately, I had spent so much time trying to understand the reason of errors until I found this posting. Thank you Max!

Thursday, April 9, 2009

Launching and closing Internet Explorer

One can run Internet Explorer in visible or invisible mode, then navigate any url and close the application, finally.

static void TestIE(Args _args)
{
COM c = new COM("InternetExplorer.Application");
str url = "http://msdn.microsoft.com/en-us/library/ms952618.aspx";
;
c.navigate(url);
c.visible(true);
if (DialogButton::Yes == BOX::YesNo("To close the browser press Yes", DialogButton::Yes))
{
info(strfmt("Job is done"));
c.quit();
}
}