It works fine without variant if you convert to string before calling Excel. And if you use excel.ScreenUpdating(false) it will work faster and more nice.
And at last if you set the workbooks Saved property to true, Excel will not ask then user for saving.
Regards Lars Nielsen
static void TestDataToExcel(Args _args)
{
CustTable custTable;
int rowCounter;COM excel; COM workBooks, workBook ; COM workSheets, workSheet; COM cell;
excel = new COM("Excel.Application");
excel.visible(true);workBooks = excel.workBooks() ; workBook = workBooks.add() ; workSheets = workBook.workSheets() ; workSheet = workSheets.item(1) ; excel.ScreenUpdating(false);
rowCounter = 1;
while select * from custtable
{
cell = workSheet.range("A" + int2str(rowCounter));
cell.value(any2str(custTable.AccountNum)); cell = workSheet.range("B"+ int2str(rowCounter));
cell.value(any2str(custTable.Name));rowCounter++; }
excel.ScreenUpdating(true); workBook.Saved(true); }
--- In [EMAIL PROTECTED], amar senapati <[EMAIL PROTECTED]> wrote:
Thanks Thomas,
you are right.
i am using office XP.so value2() method works for
office Xp.
thanks again.
Regards
Amar
--- Thomas Jensen <[EMAIL PROTECTED]> wrote:
> Hi Amar
> > The parameter for the value propery depends on the
> version of Excel. In
> Excel 2002 (version 10 installed with Office XP) it
> should be a variant as
> in your code, but in older versions (Office 2000) it
> should be a string (as
> far as I remember). Check the version of Excel you
> are using and the
> documentation of the Object model for that version.
> You could even do this
> in your code by calling excel.version() to make it
> compatible with both
> versions of Excel.
> By the way in Excel 2002 there's also a property
> value2 compatible with the
> value property in older versions!
> Good luck!
> > Regards
> Thomas Jensen
> > > > -----Oprindelig meddelelse-----
> Fra: amar senapati
> [mailto:[EMAIL PROTECTED] > Sendt: 5. september 2003 11:00
> Til: [EMAIL PROTECTED]
> Emne: [tadorna-axapta] Run time error during writing
> a tables data in an
> excel work sheet through coding
> > Hi all,
> i am finding this run time error when i am trying to
> enter one Tables data to an excel worksheet through
> coding.
> > code -----
> > CustTable custTable;
> int rowCounter;
> > > > COM excel;
> COM workBooks, workBook ;
> COM workSheets, workSheet;
> COM cell;
> COMVariant variant;
> > > > excel = new COM("Excel.Application");
> > > excel.visible(true);
> > > workBooks = excel.workBooks() ;
> workBook = workBooks.add() ;
> workSheets = workBook.workSheets() ;
> workSheet = workSheets.item(1) ;
> > > variant = new
> COMvariant(COMVariantInOut::OUT,
> COMVariantType::VT_BSTR) ;
> > > rowCounter = 1;
> > > > while select * from custtable
> {
> variant.bStr(custTable.AccountNum) ;
> cell = workSheet.range("A" +
> int2str(rowCounter)); > cell.value(variant);
> > > > variant.bStr(custTable.Name) ;
> cell = workSheet.range("B"+
> int2str(rowCounter));
> cell.value(variant);
> > > > rowCounter++;
> }
> > > The erroor comes -------: " Function 'value'
> returned error code 0x80020005 (DISP_E_TYPEMISMATCH)
> which means: One or more of the arguments could not
> be
> coerced "
> > The excel workshhet opens with no data.
> can anyone tell me why this error comes and whats
> the
> solution.
> Thanks
> Amar
> > > __________________________________
> Do you Yahoo!?
> > > __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site
> design software
> http://sitebuilder.yahoo.com
> > > > > Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/ > >
__________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com
Yahoo! Groups Sponsor
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

