Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default About _Workbook::SaveAs in Excel 2007

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default About _Workbook::SaveAs in Excel 2007

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" wrote in message ...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 question involving SaveAs to .XLS Kirk Bubul Excel Discussion (Misc queries) 3 October 17th 09 03:01 PM
method 'SaveAs' of object '_Workbook' failed Kishi Excel Programming 1 July 12th 06 03:51 AM
Method 'CheckIn' of object '_workbook' failed Bill Schanks Excel Programming 1 May 9th 06 10:04 PM
_Workbook::SaveAs(...) Fritz Hilgemann Excel Programming 2 June 16th 05 03:39 PM
SaveAs and Excel Automation L Norton Excel Programming 6 May 24th 04 07:12 AM


All times are GMT +1. The time now is 02:43 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"