|
I've succeded in writing into an excelfile from c-application
My problem ist that i want to write an formula into an excelcell.
Many Excel-formulas like =LN(C9) or =PI() do their work
But wenn i use e.g. =Summe(A9:A11) it only writes the text into the cell but it doesn't calculate the sum.
codeexample:
pExcel->Range["Tabelle1!C7"]->Formula="=SUMME(A9:A11)"; //this doesn't work
pExcel->Range["Tabelle1!C7"]->Formula="=LN(C9)"; //this does the job
any ideas why this doesn't work with summe?
|
|
|
|
|
I don't think that "=SUMME(A9:A11)" is an Excel function. Its not listed in the help file.
Try =SUM(A9:A11)
|
|
|
|
|
oh sorry i've got the german version of excel
in your case your right
but its not only a problem of Summe (or Sum) the same problem with Varianz and some other funktions.
if i open the excelfile klick to edit the formula and klick then enter without editing it works
but this is no acceptable solution
the file which i want to create has over 1000 lines and formulas.
i can't klick every cell
who to fix it?
|
|
|
|
|
Sorry.
Have you tried changing the cell format to "General" if it is "Text" it may not calculate. I doubt that is the problem though. This got over my head real quick . If I think of anything else I will let you know.
|
|
|
|
|
yes i've tried changing cell format but without succes
If he(excel) would think it is text then there would be a ' in front of the text but there isn't.
He writes #Name? (i don't know what he would write in the english version)in the cell until i click it then it works
other ideas?
|
|
|
|
|
#Name? is what I got with the English version of Excel.
|
|
|
|
|
The reason will be that "Name" is in english and in german the same word
|
|
|
|
|
I browsed through "Excel Developers Kit" book from Microsoft Press, I did not see anything. Sorry
|
|
|
|
|
@kjessee
Doesn't matter. One could not know anything. Thanks for your tips
Perhaps another one has an idea
|
|
|
|
|
|
I am trying to write a DLL to be called from VB. Thus I had to use SAFEARRAY.
I have a problem that when I am accessing all the elements in the array I can change their values but when I try to access a specific element it seems not to accept the new value I try to assign.
For example, I have these functions:
void Set2DSafeArrayPtr(SAFEARRAY * psaiInOut, long val)
{
long ai[2];
int x,y;
LRESULT hres;
int xMin = psaiInOut->rgsabound[0].lLbound;
int xMax = xMin + (int)psaiInOut->rgsabound[0].cElements - 1;
int yMin = psaiInOut->rgsabound[1].lLbound;
int yMax = yMin + (int)psaiInOut->rgsabound[1].cElements - 1;
// Set up dimension array and pointer to receive value.
long * piInOut;
if (hres = SafeArrayLock(psaiInOut)) throw hres;
for (x = xMin; x <= xMax; x++) {
ai[0] = x;
for (y = yMin; y <= yMax; y++) {
ai[1] = y;
hres = SafeArrayPtrOfIndex(psaiInOut, ai, (void **)&piInOut);
if (hres) throw hres;
// Equivalent to: aiInOut(x, y) = aiInOut(x, y) + 1.
(*piInOut) = val;
}
}
if (hres = SafeArrayUnlock(psaiInOut)) throw hres;
}
void SetElementPtr(SAFEARRAY * psaiInOut, int x, int y, long val)
{
LRESULT hres;
long * piInOut;
long ai[2];
if (hres = SafeArrayLock(psaiInOut)) throw hres;
ai[0] = x;
ai[1] = y;
hres = SafeArrayPtrOfIndex(psaiInOut, ai, (void **)&piInOut);
if (hres) throw hres;
(*piInOut) = val;
if (hres = SafeArrayUnlock(psaiInOut)) throw hres;
}
my program
void main{
...
SAFEARRAYBOUND bDim[2];
bDim[0].lLbound = 0;
bDim[0].cElements = 6;
bDim[1].lLbound = 0;
bDim[1].cElements = 6;
psaiNew = SafeArrayCreate(VT_I4, 2, bDim);
if(psaiNew == NULL){
cout << "Unable to initialize array. Not enough memory" << endl;
return;
}
hres = SafeArrayLock(psaiNew);
Set2DSafeArrayPtr(psaiNew, 15);
SetElementPtr(psaiNew, 1,2,30);
hres = SafeArrayUnlock(psaiNew);
...
}
The Set2DSafeArrayPtr seems to work fine but the SetElementPtr doesn't seem to work.
Any idea why? What am I doing wrong?
I'd also like to know of a good place I can find references/examples (other then MSDN)...
|
|
|
|
|
I added a menu to a dialog application, and can't seem to get the UPDATE_COMMAND_UI behavior to work. If I break on my OnUpdate... handler, it's called after the menu item has been selected, not before. I've been poking around on Code Project, and I'm starting to get the "impression" that it might not be possible.
Is that true, or is there a way to update a menu item in a dialog app?
|
|
|
|
|
One solution is to implement OnInitMenuPopup().
-----
void CDlgApp::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
{
// Enables this dialog based app to handle ON_UPDATE_COMMAND_UI messages.
// For updating items in menu.
CDialog::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
CCmdUI cmdUI;
cmdUI.m_pMenu = pPopupMenu;
cmdUI.m_nIndexMax = pPopupMenu->GetMenuItemCount();
for (cmdUI.m_nIndex = 0; cmdUI.m_nIndex < cmdUI.m_nIndexMax; cmdUI.m_nIndex++)
{
cmdUI.m_nID = pPopupMenu->GetMenuItemID(cmdUI.m_nIndex);
if (cmdUI.m_nID == 0)
continue;
cmdUI.DoUpdate(this, FALSE);
}
}
-----
Kuphryn
|
|
|
|
|
Thanks, I'll give it a try.
|
|
|
|
|
I get an Access Violation when executing pPopupMenu->GetMenuItemCount()
in your example.
Here's where it occurs...
_AFXWIN_INLINE UINT CMenu::GetMenuItemCount() const
{ ASSERT(::IsMenu(m_hMenu)); return ::GetMenuItemCount(m_hMenu); }
|
|
|
|
|
It looks like pPopupMenu is not setup properly prior to the call to OnInitMenuPopup. I tried executing the following command...
pPopupMenu->GetMenuState(0,MF_BYPOSITION);
and it also results in an access violation.
Oh Well.
An Ideas?
|
|
|
|
|
Add a handler for WM_KICKIDLE . In the handler, call UpdateDialogControls(this, false); You'll need to #include <afxpriv.h> for the definition of WM_KICKIDLE
--Mike--
Yeah, payin' the bills with my mad programming skillz.
Defraggin' my hard drive for thrills.
Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
Seems like a losing battle... The ON_UPDATE_COMMAND_UI message handler is still never called.
Oh well.
|
|
|
|
|
Look for 'Q242577' in MSDN, there is an example 80 lines of code overriding the OnInitMenuPopup function and it worked for me.
|
|
|
|
|
Hey! That did the trick, thanks.
|
|
|
|
|
I am working on a project where I need to set the region of numerous windows not owned by my application. This works great on 2000 but in testing on a 98se box, I found it gives an "invalid parameter" error(87) when the winow handle passed into setwindowrgn is no associatd with the application calling the function. I cannot find any documentation from MS that eludes to the fact this is not allowed and only occurs on 9x boxes. Does anyone know of a workaround or way to correct this issue. To test - create an app that sets a window region and use FindWindow to get the handle of a running instance of Notepad and try to change the shape of notepad. Keep in mind this works fine on 2000 but not on my 98se machine.
Thanks in Advance.....
|
|
|
|
|
Hi:
i want to record Telephone-conversation through my modem as a Wave File or other format such as mp3 and etc,so can anyone introduce to me an article that discuss in this field.(with source code and tutorial)
Best Regards.
|
|
|
|
|
Hi all,
I am trying to port a VB application (Playwave.exe) that can be downloaded from the microsoft website to C++. I am basically done, but there is just one small thing:
The GDI routine in VB calls a function called
Line (lastX, leftYOffset + lastLeftY)-(x, curLeftY + leftYOffset)
I translated it to C++ as follows:
pDc->MoveTo(lastX, leftYOffset + lastLeftY);
pDc->LineTo(x, curLeftY + leftYOffset);
However, the outputs that I get are quite different. The VB call paints the wave as a filled polygon while I get a bunch of interconnected lines, of course. Is there an equivalant to this Line function in C++. The Line method is defined as in MSDN:
I tried using methods like Polygon and Polyline but to no avail. BTW: i am not using MFC. Since, I am still in the learning stage, I thought it would be nice to be comfortable with core WINAPI and get a hang of how things work behind the scenes.
Syntax
object.Line [Step] (x1, y1) [Step] - (x2, y2), [color], [B][F]
You can also download the Playwave.exe from
http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B182983[^]
Thanks for any help that you might give me.
Pankaj
Without struggle, there is no progress
|
|
|
|
|
Hello !!
I have a Problem:
I have an MDI Application, and I split the Child- windows into 2 Views.
These I do in the PreCreateClient () - Funktion from CChildWnd . I habe a static Splitter with 2 columnes and 2 Views. Now I want to switch the second view away, that only the first view is visible.
Normally I must destroy the child window and then I create it without splitter.
But I want by Programm (not by user) switch the second view away without destroying the child window. Can I make the second view not destroying, only the client- area make it to CRect (0,0) ??
Thank you for helping me
Dirk from Germany
|
|
|
|
|
Cany anyone comment on why some people will use:
<br />
int main(int argc, char** argv){}<br />
compared to the MFC app-wizard generated:
<br />
int main(int argc, char* argv[]){}<br />
Thanks.
|
|
|
|