Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Can't add a reference to specified file

Hi,

About a year ago I wrote C++ excel add-in, which provides a few worksheet
function which I still use quite frequently and successfully. Now I want to
use the same function in VBA. From what I understand, I need to add a
reference to the add-in first, but when I pick my xll from the browse menu,
I get the "Can't add a reference to specified file" error. Something is
probably screwed inside my xll. Can you recommend what I should look at.

Many thanks!

Bura.

PS: The function that I want to use is one that takes a URL and returns the
contents of that resource. In particular, I'm running a few servers and I
need for my VBA code to find the live ones. So I request an
http://serverN/AreYouAlive.jsp, and the server replies "yes" and my function
passes it through, or the request time outs and my function returns "no". In
VBA I would like to be able to say if getURL(http://serverN/AreYouAlive.jsp)
= "yes"... Perhaps someone could suggest an alternative way of doing this
and then the primary question is this post will become moot. Thanks again.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Can't add a reference to specified file

If it is a xll/dll, I believe you would declare it just like a windows API.
(rather than set a reference to it).

This article gives an example of making a DLL and calling it from VB (should
be the same for VBA).

http://support.microsoft.com/default...46&Product=vbb

Include the path if it isn't in the system directory I believe.
HOWTO: Pass Optional Parameters to a C DLL Function from VB

--
Regards,
Tom Ogilvy


"Bura Tino" wrote in message
...
Hi,

About a year ago I wrote C++ excel add-in, which provides a few worksheet
function which I still use quite frequently and successfully. Now I want

to
use the same function in VBA. From what I understand, I need to add a
reference to the add-in first, but when I pick my xll from the browse

menu,
I get the "Can't add a reference to specified file" error. Something is
probably screwed inside my xll. Can you recommend what I should look at.

Many thanks!

Bura.

PS: The function that I want to use is one that takes a URL and returns

the
contents of that resource. In particular, I'm running a few servers and I
need for my VBA code to find the live ones. So I request an
http://serverN/AreYouAlive.jsp, and the server replies "yes" and my

function
passes it through, or the request time outs and my function returns "no".

In
VBA I would like to be able to say if

getURL(http://serverN/AreYouAlive.jsp)
= "yes"... Perhaps someone could suggest an alternative way of doing this
and then the primary question is this post will become moot. Thanks again.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Can't add a reference to specified file


"Tom Ogilvy" wrote in message
...
If it is a xll/dll, I believe you would declare it just like a windows

API.
(rather than set a reference to it).

This article gives an example of making a DLL and calling it from VB

(should
be the same for VBA).

http://support.microsoft.com/default...46&Product=vbb

Include the path if it isn't in the system directory I believe.
HOWTO: Pass Optional Parameters to a C DLL Function from VB

--


Thanks Tom. Couldn't quite get it to work. So I'll post more info and
perhaps you or someone else could suggest the precise declaration to use.

1. Function Registering Table:
static LPSTR func[][14] = {
{ " getURL" , " RP" , " getURL" , " URL String" , " 1", " Transcend", " ", "
", " Non Volatile NOW()" , " This dummy dependency argument is unused inside
the funtion", " ", " ", " ", " "},
};

2. The DEF file snippet:
getURL


3. And here's the very ugly getURL function (but it works)

LPXLOPER __stdcall getURL(LPXLOPER inX) {
static XLOPER xRes;
Excel4(xlfNow, &xRes, 0); // Returns an xltypeNum;
xRes.xltype = xltypeStr;
xRes.val.str = (PUCHAR) " Input not a URL";
if (inX-xltype == xltypeStr) {
string *a = new string(" " + utilityURLToString(toStr(inX-val.str))); //
a function that uses the curl package compiled into the addin.
xRes.val.str = (PUCHAR) a-c_str();
xRes.val.str[0] = a-length() - 1;
xRes.xltype = xltypeStr;
}
return &xRes;
}


This works beautifully in worksheets and I want to have the function getURL
available in VBA!


Very many thanks!!! I would be exstatic if I can get this to work and I
think this will be useful to others as well!

(Hopeful) Bura



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linking to another file using file reference typed cell Steven Excel Worksheet Functions 3 April 5th 08 03:15 AM
cross-reference data from one file to another file Zancouth Excel Discussion (Misc queries) 1 May 30th 06 11:25 AM
How do I reference external data from a file, file name found in . Clux Excel Discussion (Misc queries) 1 February 10th 05 10:52 PM
copy/paste from one file to another without file name reference slvrblt Excel Discussion (Misc queries) 4 February 6th 05 08:57 PM
reference to .dll file Claude Excel Programming 1 November 21st 03 03:34 PM


All times are GMT +1. The time now is 01:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"