|
Hi !
Is there any documentation about the excel automation classes ? I'm trying to set the format of a range of cells as "centered" and "text", but i do not know how to do it.
lpDisp = sheet.GetRange(COleVariant(start), COleVariant(start));
ASSERT(lpDisp);
range.AttachDispatch(lpDisp);
Here ...
range.SetValue(COleVariant(tmp));
Thanks...
~RaGE();
|
|
|
|
|
I don't know whether there's anywhere a *real* documentation.
But opening the Excel help, then choosing the topic Programming Information -> Microsoft Visual Basic Reference gives you an overview of all available objects, methods, ...
We are men. We are different. We have only one word for soap. We do not own candles. We have never seen anything of any value in a craft shop. We do not own magazines full of photographs of celebrities with their clothes on. - Steve
|
|
|
|
|
In fact, if you include excel8.h in the MFC project, you can also see all the methods, object and so on. The only problem is, that the parameters of the functions are mainly COleVariant . So if i have Range::SetNumberFormat(const VARIANT& newValue) , i'm lost without documentation
Any idea ?
~RaGE();
|
|
|
|
|
Sorry, I don't know any suitable documantation.
But the "documantation" I mentioned (yes, I mean the one from Excel) tells you what type the properties have. This should be sufficiant to set the corresponding data type for your VARIANT which is passed in your function call. So f.i. the NumberFormat property is of type string, you provide a VARIANT of type VT_BSTR etc.
I know it's not very practable, but for me it works.
We are men. We are different. We have only one word for soap. We do not own candles. We have never seen anything of any value in a craft shop. We do not own magazines full of photographs of celebrities with their clothes on. - Steve
|
|
|
|
|
Could you tell me (i mean a sample code), as an example, how to have my range of cells get the "centered" property ? Because there is no SetStyle or something like that ...
Thank you very much (if you do not have time, don't bother, it is not that important..)
~RaGE();
|
|
|
|
|
The property to be set is HorizontalAlignment.
So if you have a pointer to your range, calling
range->SetHorizontalAlignment(COleVariant(xlHAlignCenter));
should work. Without use of MFC or similar, it could be more like
VARIANT var;
var.vt = ???;
var.??? = xlHAlignCenter;
range->set_HorizontalAlignment(var);
But I don't know of what type xlHAlignCenter is, so you should figure that out before setting the Variant parameter.
We are men. We are different. We have only one word for soap. We do not own candles. We have never seen anything of any value in a craft shop. We do not own magazines full of photographs of celebrities with their clothes on. - Steve
|
|
|
|
|
Schlaubi wrote:
range->SetHorizontalAlignment(COleVariant(xlHAlignCenter));
That's what I've tried from the beginning, but compiler does not know about xlHAlignCenter, so even the type cast would not fit. Anyway, i have found in Article ID: Q179706 in the MSDN, that the value for xlVAlignCenter (so the vertical alignement) is -4108, assumed this would be the same for horizontal alignement, tried ... and it worked !
So i'm done, even if i would really love to have a table giving indications like
xlHAlignCenter=-4108;
Lots of thank for your help, i own you a ...
~RaGE();
|
|
|
|
|
Rage wrote:
So i'm done, even if i would really love to have a table giving indications like
No problem
f.i. for Excel:
Search the corresponding olb / tlb file, in my case it's excel9.olb, located in program files\microsoft office\office. Then open the file with oleview, delivered with MS VS. Now you have a perfect overview of all interfaces and enums. In your case, the enum xlhalign provides you all values you need. As for all other constants, too.
We are men. We are different. We have only one word for soap. We do not own candles. We have never seen anything of any value in a craft shop. We do not own magazines full of photographs of celebrities with their clothes on. - Steve
|
|
|
|
|
That's simply great !!!
Vielen Dank !
~RaGE();
|
|
|
|
|
No problem!
C'est toujours un grand plaisir de aider. (Sorry for that bad French, but my French lessons are already 5 years gone);
We are men. We are different. We have only one word for soap. We do not own candles. We have never seen anything of any value in a craft shop. We do not own magazines full of photographs of celebrities with their clothes on. - Steve
|
|
|
|
|
Hello,
I need to place all the tabs of a property sheet in the same line and make the user scroll over them, and after reading the MSDN I've written this:
int CPSParametritzacions::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
this->EnableStackedTabs(FALSE);
if (CPSAutoRedimensionable::OnCreate(lpCreateStruct) == -1) return -1;
return 0;
} But it doesn't work...
I'm almost sure that I am missing something...
Thank you in advance.
|
|
|
|
|
what happens if you follow the MSDN example exactly. i.e.
int CMyPropertySheet::OnCreate(LPCREATESTRUCT lpCreateStruct)<br />
{<br />
EnableStackedTabs(FALSE);<br />
if (CPropertySheet::OnCreate(lpCreateStruct) == -1)<br />
return -1;<br />
return 0;<br />
}
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
int CPSParametritzacions::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
this->EnableStackedTabs(FALSE);
if (CPSAutoRedimensionable::OnCreate(lpCreateStruct) == -1) return -1;
return 0;
}
int CMyPropertySheet::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
EnableStackedTabs(FALSE);
if (CPropertySheet::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}
the only differences I see are in bold font... and I don't believe they are significant...
The fact is that this must not be the reason... (it's obvious why), but the other one... My problem is that the CPSAutoRedimensionable class it's a class derived from the base class property sheet and that I don't know why I can't call directly CPropertySheet::OnCreate from my CPSParametritzacions class.
Thank you in advance, and thank you for your interest too.
|
|
|
|
|
Hi....
I am doing a Project in which I want to close a selected port which is opened by another application. How can I Solve the Same? Which function to be used??Please Help
Thanks in Advance.
SAN
|
|
|
|
|
Do you have the source code to the other application? If so it would be easy to do. If not, I'm not sure if this could even be done.
Rob
|
|
|
|
|
What I need to do is move my existing resources from the executable into separate resource DLLs, separated by language. Does anyone have links to any tutorials, guides, or other articles about resource DLLs in general?
Jon Sagara
I have no complaint with the “mentoring concept” or the marriage concept or the sex concept. But if you pay for any of those, something’s wrong.
-- John T. Reed in The real estate B.S. artist detection checklist [^]
|
|
|
|
|
|
Microsoft Press used to have a book on Localization/Globalization.
It was pretty good at the time.
C++/MFC/InstallShield since 1993
|
|
|
|
|
dear all,
i want to write a small utility which runs in the background and detects
system shutdown.
but i have no idea about how to go about it
any suggestion will be greatly appreciated
thanx
|
|
|
|
|
|
thanx for ur timely reply
can u post some sample or direct me to some url which shows the same
thanx a ton
|
|
|
|
|
I'm trying to create a popup menu for my tree control. I've got some code and the sample I have seems to use a CPoint pointer for the x and y locations of the mouse. Can I get access to a CPoint object somehow in the code I have?
void CSacmanSetupDlg::OnRclickSacmanSetupTree(NMHDR* pNMHDR, LRESULT* pResult) <br />
{<br />
bool bDone = false;<br />
HTREEITEM hSelectedItem;<br />
<br />
CMenu newMenu;<br />
newMenu.CreatePopupMenu();<br />
bDone = newMenu.TrackPopupMenu(TPM_LEFTALIGN,15,15, <br />
AfxGetApp()->m_pMainWnd,NULL);<br />
hSelectedItem = this->m_SetUpTree.GetSelectedItem();<br />
<br />
*pResult = 0;<br />
}
Sample I'm working from...
void CAppButton::OnRButtonDown(UINT flags, CPoint point)<br />
{<br />
CMenu menu;<br />
CMenu *submenu;<br />
menu.LoadMenu(IDR_LAUNCH);<br />
submenu = menu.GetSubMenu(0);<br />
ClientToScreen(&point);<br />
submenu->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,<br />
point.x, point.y,<br />
AfxGetApp()->m_pMainWnd,NULL);<br />
}
|
|
|
|
|
GetCursorPos() will return the current position of the mouse in screen coordinates. From memory (so i may be wrong), TrackPopupMenu() wants coordinates in client coorindates, so you may need to convert it first.
Dave
|
|
|
|
|
Actually, TrackPopupMenu needs screen coordinates (your memory must be fading... ). You can pass the results of GetCursorPos() straight to TrackPopupMenu().
However, for this app you might want to use GetMessagePos(), which returns the screen position of the mouse when the last message retrieved with GetMessage() was generated.
Cheers,
Ryan
|
|
|
|
|
Many thanks, I am unworthy!
|
|
|
|