LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Can't get Excel SaveAs dialog to show

I'm trying to show the Excel SaveAs dialog from an ATL app.

In VB, the following works fine:

Application.Dialogs("xlDialogSaveAs").Show sFileName

But in ATL, I've had all sorts of trouble with getting this
to work. Here's what I have right now:

CComPtr<IDispatch m_pExcel;
HRESULT hr = m_pExcel.CoCreateInstance(L"Excel.Application", NULL,
CLSCTX_SERVER);
CComDispatchDriver cddExcel = m_pExcel;

CComVariant vTrue(TRUE);
hr = cddExcel.PutPropertyByName(L"Visible",&vTrue);

CComVariant cvDialogs;
cddExcel.GetPropertyByName(L"Dialogs", &cvDialogs);
CComDispatchDriver cddDialogs = cvDialogs.pdispVal;

CComVariant cvCount;
hr = cddDialogs.GetPropertyByName(L"Count",&cvCount);

DISPID dwDispID;
hr = cddDialogs.GetIDOfName(L"Item", &dwDispID);

CComVariant cvIndex(5); //xlDialogSaveAs
DISPPARAMS dispparams = { (VARIANT*)&cvIndex, NULL, 1, 0 };

CComVariant cvDialog;
cddDialogs-Invoke(dwDispID, IID_NULL,
LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET | DISPATCH_METHOD,
&dispparams, &cvDialog, NULL, NULL);

CComDispatchDriver cddDialog = cvDialog.pdispVal;
CComVariant vOpt(DISP_E_PARAMNOTFOUND, VT_ERROR);

CComVariant cvResult;
VARIANT vArgsShow[30];
memset(vArgsShow, 0, sizeof(VARIANT) * 30);
for(int i=0;i<30;i++)
{
vArgsShow[i] = vOpt;
}
CComVariant cvDocText("C:\\testing.xls");
vArgsShow[29] = cvDocText; //document_text
CComVariant cvTypeNum(1);
vArgsShow[28] = cvTypeNum; //type_num
CComVariant cvProtPwd("");
vArgsShow[27] = cvProtPwd; //prot_pwd
CComVariant cvBackup(FALSE);
vArgsShow[26] = cvBackup; //backup
CComVariant cvWriteResPwd("");
vArgsShow[25] = cvWriteResPwd; //write_res_pwd
CComVariant cvReadOnlyRec(FALSE);
vArgsShow[24] = cvReadOnlyRec; //read_only_rec
hr = cddDialog.InvokeN(L"Show", vArgsShow, 30, &cvResult);

return 0;

The excel instance starts up fine, I get the Dialogs object,
it has a count of over 700 dialogs, and I'm able to get the
dialog xlDialogSaveAs.

However, I can't get the invoke of the Show method to work.
I've tried all optional parms, just filename, parameters in
forward and backward order, all parameters. Nothing seems
to work.

Anybody have any ideas whats wrong here?

Thanks,

-M-
 
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
how do I write a macro to show the find dialog box in excel 2003 evets Excel Discussion (Misc queries) 1 July 6th 08 01:11 PM
Show the Outline Dialog Box TKS_Mark Excel Discussion (Misc queries) 0 May 14th 08 08:07 PM
Can you Pre-fill file name in SaveAs dialog Jive Excel Worksheet Functions 1 November 12th 07 04:30 PM
SaveAs dialog Gary''s Student Excel Discussion (Misc queries) 2 February 23rd 06 03:11 PM
SaveAs Dialog Arguments Frank Kabel Excel Programming 4 February 24th 04 07:25 PM


All times are GMT +1. The time now is 09:47 AM.

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

About Us

"It's about Microsoft Excel"