View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Peter Huang [MSFT] Peter Huang [MSFT] is offline
external usenet poster
 
Posts: 225
Default Excel4 Call to get Function String

Hi Matthew,

e.g. You have a MyFunc in xll and at A1 you using the formula
"=MyFunc(parameters)"
Then you need to call the Excel4 after the MyFunc return.
Here is my code.
XLOPER xlRef, xlFormula;
xlRef.xltype=xltypeSRef;
xlRef.val.sref.count =1;
xlRef.val.sref.ref.rwFirst = 0;
xlRef.val.sref.ref.rwLast = 0;
xlRef.val.sref.ref.colFirst = 0;
xlRef.val.sref.ref.colLast = 0 ;
Excel(xlfGetFormula, &xlFormula, 1, &xlRef);
This will restrieve the "=MyFunc(parameters)" in the xlFormula.val.str

You may have a try and let me know if this does the job for you.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
Date: Mon, 22 Sep 2003 14:09:09 -0400
From: Matthew Wieder
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4)

Gecko/20030624 Netscape/7.1 (ax)
X-Accept-Language: en-us, en, he
MIME-Version: 1.0
Subject: Excel4 Call to get Function String
References:




In-Reply-To:
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID:
Newsgroups: microsoft.public.excel.programming
NNTP-Posting-Host: 207.106.112.178
Lines: 1
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP11.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.excel.programming:418054
X-Tomcat-NG: microsoft.public.excel.programming

Yeah - I somehow combed ine net and discovered that same code segmant
which should do what I want, but the call to xlfGetFormula is failing
with a return code of 2 or "An invalid function number was supplied. If
you are using constants from XLCALL.H, this shouldn't happen." I checked
XLCall.h and xlfGetFormula is correctly defined as 106. I hope we can
solve this issue as it has become somewhat urgent for us.
thanks!

Rob Bovey wrote:

"Matthew Wieder" wrote in message
...

That is what I need, but I need the actual string, not aa version I can
reconstruct. The difference is that I need to know whether a single
cell was entered as "$B$1" or as "B1:B1" which are equivalent once the
become passed in as XLOPERS so I need to get the actual string from the
cell.



Hi Matthew,

I've never tried to do this, so I don't know for sure that there's a
solution. The following seems like it ought to work:

XLOPER xlRef, xlFormula;
Excel4(xlfCaller, &xlRef, 0);
Excel4(xlfGetFormula, &xlFormula, 1, &xlRef);

but in the quick tests I've done it doesn't. I'll play with it some more
when I get back home tonight. and post again if I can get it working.