PC Review


Reply
Thread Tools Rate Thread

About _Workbook::SaveAs in Excel 2007

 
 
=?Utf-8?B?UHJpeWFua2E=?=
Guest
Posts: n/a
 
      3rd Oct 2006
HI everybody..........

This is regarding the Excel API _Workbook::SaveAs.......

I have written some code in VC++ to save any excel sheet at a particular
place of my choice using my ExcelAddin.

It works fine with office 2000/2003.

Here it is,


VARIANT vt_Format;
VariantInit(&vt_Format);
vt_Format.vt = VT_I4;
vt_Format.lVal = GetFormat(nFormat);

VARIANT vt_Optional;
vt_Optional.vt = VT_ERROR;
vt_Optional.scode = DISP_E_PARAMNOTFOUND;
_bstr_t bstrFilePath(strFilePath.operator LPCTSTR());
VARIANT vt_FilePath;
VariantInit(&vt_FilePath);
vt_FilePath.vt = VT_BSTR;
vt_FilePath.bstrVal = bstrFilePath;

try
{
CExcelDMSConnect::m_bFirstSave = TRUE;

hr = pBook->SaveAs(vt_FilePath,
t, -----------------------------XYZ
vt_Optional, vt_Optional, vt_Optional,
vt_Optional, xlNoChange, vt_Optional,
vt_Optional, vt_Optional, vt_Optional, 0);
CExcelDMSConnect::m_bFirstSave = FALSE;
if(FAILED(hr))
{
AfxMessageBox(IDS_ERR_SAVEAS_DOC);
return;
}
}
catch(_com_error e)
{
_bstr_t description=e.Description();
_bstr_t errmsg=e.ErrorMessage();
CString strDes=OLE2T(description);
CString strErrMsg=OLE2T(errmsg);

}


When i execute the line labelled
"......................................XYZ", the _com_error exception is
thrown by office API.
When i look at Desription of the exception, it shows a null string and the
Errormessage is "Unknown Error".

I am using mso9.dll

I don't know what is wrong with it and why this API fails...........
Has the API for this purpose been changed??????????


Any help would be appreciable.

Thanks and Regards,
Priyanka
 
Reply With Quote
 
 
 
 
Ron de Bruin
Guest
Posts: n/a
 
      3rd Oct 2006
> I have written some code in VC++
Can't help you with that

But maybe this page is useful for you
http://www.rondebruin.nl/saveas.htm


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Priyanka" <(E-Mail Removed)> wrote in message news:6A24A6F7-51B5-408A-9F5E-(E-Mail Removed)...
> HI everybody..........
>
> This is regarding the Excel API _Workbook::SaveAs.......
>
> I have written some code in VC++ to save any excel sheet at a particular
> place of my choice using my ExcelAddin.
>
> It works fine with office 2000/2003.
>
> Here it is,
>
>
> VARIANT vt_Format;
> VariantInit(&vt_Format);
> vt_Format.vt = VT_I4;
> vt_Format.lVal = GetFormat(nFormat);
>
> VARIANT vt_Optional;
> vt_Optional.vt = VT_ERROR;
> vt_Optional.scode = DISP_E_PARAMNOTFOUND;
> _bstr_t bstrFilePath(strFilePath.operator LPCTSTR());
> VARIANT vt_FilePath;
> VariantInit(&vt_FilePath);
> vt_FilePath.vt = VT_BSTR;
> vt_FilePath.bstrVal = bstrFilePath;
>
> try
> {
> CExcelDMSConnect::m_bFirstSave = TRUE;
>
> hr = pBook->SaveAs(vt_FilePath,
> t, -----------------------------XYZ
> vt_Optional, vt_Optional, vt_Optional,
> vt_Optional, xlNoChange, vt_Optional,
> vt_Optional, vt_Optional, vt_Optional, 0);
> CExcelDMSConnect::m_bFirstSave = FALSE;
> if(FAILED(hr))
> {
> AfxMessageBox(IDS_ERR_SAVEAS_DOC);
> return;
> }
> }
> catch(_com_error e)
> {
> _bstr_t description=e.Description();
> _bstr_t errmsg=e.ErrorMessage();
> CString strDes=OLE2T(description);
> CString strErrMsg=OLE2T(errmsg);
>
> }
>
>
> When i execute the line labelled
> "......................................XYZ", the _com_error exception is
> thrown by office API.
> When i look at Desription of the exception, it shows a null string and the
> Errormessage is "Unknown Error".
>
> I am using mso9.dll
>
> I don't know what is wrong with it and why this API fails...........
> Has the API for this purpose been changed??????????
>
>
> Any help would be appreciable.
>
> Thanks and Regards,
> Priyanka



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run-time error 1004 Method SaveAS of object _Workbook failed David Microsoft Excel Programming 2 18th Dec 2008 08:38 PM
excel 2007 saveas greg Microsoft Excel Programming 0 28th Aug 2008 08:56 PM
Excel 2007 COM: Using SaveAs from PowerShell Marco Shaw Microsoft Excel Programming 2 9th Sep 2007 02:44 AM
method 'SaveAs' of object '_Workbook' failed =?Utf-8?B?S2lzaGk=?= Microsoft Excel Programming 1 12th Jul 2006 03:51 AM
_Workbook::SaveAs(...) Fritz Hilgemann Microsoft Excel Programming 2 16th Jun 2005 03:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:20 PM.