Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My code is something link this
using namespace Excel;
int main(array<System::String ^> ^args)
{
    Excel::_ApplicationPtr pXL;
    pXL.CreateInstance(L"Excel.Application.8");
    pXL->Visible = VARIANT_TRUE;//generates this error
/*
error C2660: 'Excel::_Application::PutVisible' : function does not take 1 arguments
*/
    ...
}

Visible is a property and it must have 1 argument.
How can I resolve this error?
Thanks in forward
abzadeh
Posted
Updated 5-Nov-16 10:04am

The Visible property is a boolean, so the erroneous line should be

pXL->Visible = true;
 
Share this answer
 
v2
Comments
mr.abzadeh 15-Apr-11 15:29pm    
my browser (IE8) does not show reply icon, so I use addcomment.

What U mean by pXL->true;? It does not seem correct. I examined it however, and result was this error
<pre>error C2059: syntax error : 'constant'</pre>
I alse examined this code
<pre>pXL->PutVisible( VARIANT_TRUE, 1 );</pre>
It Complied successfully, meaning that PutVisible needs 2 arguments, but I dont know
their meaning
thanks
Graham Shanks 15-Apr-11 19:02pm    
Sorry, I missed out some text, it should be pXL->Visible = true; (I've updated the solution appropriately).

PutVisible does not appear in the interface for the Excel Application class, according to the documentation with VS 2005. It may be due to the microsoft extension to implement prperties in C++ (which does not support them).

A google search seems to suggest that pXL->PutVisible(0, TRUE); would set the visible flag. TRUE is a hash define for a non-zero value. It was used for booleans in C, before C++ introduced the bool, true and false keywords. VARIANT_TRUE is a has define for ((VARIANT_BOOL)1), where VARIANT_BOOL is a hash define for short
mr.abzadeh 16-Apr-11 2:04am    
I examined this code, causes the same error.
pXL->Visible = true;//generates this error
/*
error C2660: 'Excel::_Application::PutVisible' : function does not take 1 arguments
*/
PutVisible is a wrapper function generated in mymodule.tli, which is follows
<pre>inline void Excel::_Application::PutVisible ( long lcid, VARIANT_BOOL RHS ) {
HRESULT _hr = put_Visible(lcid, RHS);
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
}</pre>
I dont know what arguments lcid and RHS means for, but a 'true' value for RHS with any value for lcid works.
Can you post me the address of links you found about PutVisible? I need this to find the meaning of 'lcid' amd 'RHS' arguments and other information.
Thanks for your point out
abzadeh
Graham Shanks 16-Apr-11 11:25am    
The links I found last night would not help you about the arguments. However with your extras information, I found this link[^]. Right at the bottom of the first page, it states the lcid is the locale identifier, and setting it to NULL (i.e. 0) uses the computer's default - which is almost certainly what you want to do. RHS is a bit easier to decode, it stands for "Right Hand Side", which is a standard way of referring to the term on the right of the assignment statement - for instance, you'll often see the assignment operator written as MyClass& MyClass::operator=(const MyClass& RHS);

I also found this link[^], which states the the Visible property is of type System::Boolean. So you could try

object trueValue = true;
pXL->Visible = trueValue;

or

pXL->Visible = (System::Boolean)true;

Of course, I think that pXL->PutVisible(0, TRUE); is probably sufficient
mr.abzadeh 16-Apr-11 12:18pm    
Formerly I used office 2003 and _Application.Visible = TRUE worked well.
I think that since office 2007, Microsoft offers Visible property with 2 arguments, and hides The 1 argument one. I say 'Hides' because code written for office 2003 should and does work in office 2007 and 2010.
My question has been answered completely.
Thanks for your help and the links you found for me, Good luck
Abzadeh.
I also have the problem,I have tried the above suggestions,but it doesn't work,can I have your demo Project? I want to know the reason,thanks
 
Share this answer
 
pXL->PutVisible(0,VARIANT_TRUE);
 
Share this answer
 
Comments
Dave Kreskowiak 5-Nov-16 16:24pm    
This was solved FIVE YEARS AGO! Don't add another answer to old questions that are already solved.
pavfrang 5-Nov-16 16:34pm    
The Solution 1 is wrong and misleading.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900