|
I am trying to access an Excel spreadheet in Visual C++ 6.0. I am using the XL5EN32.OLB library. However I keep getting errors, one of which is:
error C2440: 'type cast' : cannot convert from 'class Sheets' to 'class COleVariant'
I just wanted to be able to pull data out of a spreadsheet and use it in my program. There are problems with Ole. I thought you could define a sheet from the workbook object. However it does not allow me to do this. You have do get sheets from a workbook and a workbook from a file. But I can not do this, the return types don't match. I looked at MSDN article 179706
http://support.microsoft.com/default.aspx?scid=kb;EN-US;179706
It doesn't seem to work that way though. I don't know how they got the return types to match.
COleVariant fn;
CString f;
Application app;
Workbooks books;
Workbook book;
Range pRange;
Sheets sheets;
double Result;
COleVariant
covTrue((short)TRUE),
covFalse((short)FALSE),
covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
app.CreateDispatch("Excel.Application");
app.SetVisible(covTrue);
books.Open(fn, covOptional, covOptional, covOptional, covOptional,
covOptional, covOptional, covOptional, covOptional,
covOptional, covOptional, covOptional);
sheets = book.Sheets(COleVariant((short)(1)));
|
|
|
|
|
There are some internal logic that you need to handle.
The way to correct this is.
LPDISPATCH lpDisp;
lpDisp = book.Sheets(COleVariant((short)(1)));
ASSERT(lpDisp);
sheets.AttachDispatch(lpDisp);
I have not tested it but it should be that kind of style down the road using AttachDispatch(...)
Sonork 100.41263:Anthony_Yio
Life is about experiencing ...
|
|
|
|
|
I get the following error when I try
LPDISPATCH lpDisp; lpDisp = book.Sheets(COleVariant((short)(1))); ASSERT(lpDisp); //some checking sheets.AttachDispatch(lpDisp);
error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'struct tagVARIANT' (or there is no acceptable conversion)
|
|
|
|
|
Try
LPVARIANT lpVar = (book.Sheets(COleVariant((short)(1)))).operator LPVARIANT( );
LPDISPATCH lpDispatch;
if(lpVar->vt == VT_DISPATCH)
{
lpDispatch = lpVar->ppdispVal;
}
else
{
ASSERT(NULL);
}
sheets.AttachDispatch(lpDisp);
Sonork 100.41263:Anthony_Yio
Life is about experiencing ...
|
|
|
|
|
I have a modal dialog box that I would like to go modaless if a button is clicked on and then back to a modal state after the buttons action has ended.
I have tried EndModalDialog but with no success, does anyone know a command that can help me?
|
|
|
|
|
Just call yourDialog.DoModal() for modal dialog.
and yourDialog.Show() for modeless.
There are plenty of tutorials on modeless dialog in codeproject.
Sonork 100.41263:Anthony_Yio
Life is about experiencing ...
|
|
|
|
|
I want the Dialog Box to be modal unless the button is clicked.
If they never click the button then the dialog box should just be
modal the entire time.
What I am trying to do is: if a user clicks on a button then it opens a doc/view window where they can make a choice that sends them back to the dialog box which would return to its modal state.
Thanks
|
|
|
|
|
I think Gary R. Wheeler suggestion is implementable.
Like
((YourParentDlg*)this->GetParent())->EnableWindow(FALSE);
Anyway, I think the logic behind is and should lie under you.
Sonork 100.41263:Anthony_Yio
Life is about experiencing ...
|
|
|
|
|
Probably the easiest way to do this is to have the dialog be modeless all of the time, and then simulate modality by having the dialog disable/enable the parent window as necessary.
Software Zen: delete this;
|
|
|
|
|
Hi,
I am working on win32 api, I want to apply ALT+TAB functionality for our programming. Actually I want to get the taskbar running application. ALT+TAB functionality is fulfilling, so can u one please send me a suggestion to get handle of the application, which is running on taskbar only.
Thanks in Advance
Baskar
|
|
|
|
|
i don't understand. what do you want? get the HWND to the task bar? get the process id to the process controlling the task bar?
Don't try it, just do it!
|
|
|
|
|
Hi Alxander,
Thanks for your immediate reply for the same. I need to get all top level windows to show the application icons on our product. In our product we are having one tooltip window, which is used for display all icons of top level windows (all taskbar application windows). It seems like ALT+TAB window. Samething like I need to create one window inside our product. For that I need to get all top level windows. Can u please help the same how to get top level windows.
Thanks in Advance
Baskar
|
|
|
|
|
the following is my doing:
in precreatewindow()
cs.style|=MINIMIZEBOX;
but doesnt work,somebody can give me some advice and explanination?
thx
|
|
|
|
|
Are you creating the dialog at runtime, or toggling the min/max on and off buttons while the dialog is running?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
there are 2 better ways. if you are using a dialog resource then change the dialog settings with the resource editor (there is an option for min/max button). the other way is to change the window style run-time.
DWORD dwLong;
dwLong = GetWindowLong( hWnd, GWL_STYLE );
dwLong |= WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
SetWindowLong( hWnd, GWL_STYLE, dwLong );
Don't try it, just do it!
|
|
|
|
|
If in MFC, I think ModifyStytle() works the same way.
<code>
ModifyStyle(0, WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
I have a little problem when making this style changes in run time tho. I placed it at the end of OnInitDialog() and the changes is made sucessfully. But at the first time the dialog appears, the MAXIMIZE and MINIMIZE icons (just the icons) are still on the menu bar, until the window is refreshed (e.g. switch to other dialog and switch back). Is this normal?
|
|
|
|
|
Is there a way of enumerating DDE Servers on a computer?
I would like to see which programs accept DDE messages on my local computer?
Orcun Colak
|
|
|
|
|
Is DdeConnectList() of any help.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I have developed a Simple MFC GUI to allow a user to display and control an activity.
The program works fine on a PC with Visual Studio installed, but when I transfer the program
to a Laptop computer I get an Assertion Failure line 410 of file occmgr.cpp.
I built a Deployment & Install project to formally install the program, but still keep getting the same error. It works fine on a desktop PC without Visual Studio installed.
I was told that Assertions are present only in debug builds, and debug builds cannot be
and should not be deployed.
I have now built the application in 'Release' mode, but now need to install the .Net framework.
How do you do that?!?
|
|
|
|
|
Check out commercial installer such as InstallShield. It can package the .NET runtimes. You can give the user the link to download .NET Framework at MSDN.
Kuphryn
|
|
|
|
|
it is because you built your application with Visual studio .NET, and the user that execute then don't have this framework.
run windows update and search for the .NET framework
TOXCCT >>> GEII power
|
|
|
|
|
I downloaded the dotnetfx.exe and installed it on the other PC but still get an Assertion Error on Line 410 of occmgr.cpp.
I think I built a 'Release' version of the program, as it reported during the duilt process that the .Net framework is required on the target machine.
What now!?!
|
|
|
|
|
P.S., if you still get an "Assert" error, that means you are still running the Debug version!
"Fish and guests stink in three days." - Benjamin Franlkin
|
|
|
|
|
What do you need to do to build a Release Version?
I am struggling here!
|
|
|
|
|
There is a combo box near the menus that probably says "Debug". You should just be able to change this to "Release", and rebuild all, and it will work. Notice that the release build usually goes in a different directory, e.g.:
C:\Your Project\Release\YourProgram.exe
.. as opposed to the Debug, which goes in (unless you've changed it), something like:
C:\Your Project\Debug\YourProgram.exe
You'll notice the Release executable is about half the size as the Debug one.
"Fish and guests stink in three days." - Benjamin Franlkin
|
|
|
|