LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

how can i put HyperLink into exel throgh CVI

Hello , I'm trying to use HyperLink in exel through CVI but i'm getting an error code: -2147467262
when i'm using Exel_HyperLinksAdd function.
 
do you now what this ERROR code means?
0 Kudos
Message 1 of 6
(5,153 Views)
-2147467262 is 0x80004002 which is 'This interface is not supported'. Which version of Excel are you using? Have you generated the controller function panel for it yourself, or are you using the one supplied by NI? If you are using the NI one, try generating your own from the ActiveX control.
--
Martin
Certified CVI Developer
0 Kudos
Message 2 of 6
(5,147 Views)

Thank you for your quick answer..

I'm using Microsoft Exel 2003.

I didn't understand your question' what do you mean "Have you generated the controller function panel for it yourself, or are you using the one supplied by NI?".

I'm using exel function panel from NI samples.

I'm adding part of the code that make me the Error:

error = Excel_SheetsItem (worksheets, NULL, CA_VariantInt(2),//sheet number
                              &worksheet);
 /* -------------------------------------------------- */ 
 /* Make Sheet Active - should already be active       */
    /* -------------------------------------------------- */ 
   
 error =     Excel_WorksheetActivate (worksheet, NULL);

  error = CA_VariantSetCString (&VSubAddress, "MA1xx001!A1");
 error = CA_VariantSetCString (&VTextToDisplay, "MA1xx001");
 error = CA_VariantSetCString (&MyCellRangeV, "B3");
 
 error = Excel_WorksheetRange (worksheet, NULL, MyCellRangeV, CA_DEFAULT_VAL, &ExcelRangeHandle);  
 
 error = Excel_HyperlinksAdd (worksheet, NULL, ExcelRangeHandle, "", VSubAddress,
        CA_DEFAULT_VAL, VTextToDisplay, &error);

This last line generate me the Error.

 

 

0 Kudos
Message 3 of 6
(5,144 Views)

Most of the time, the reason for this type of error is that some feature of the ActiveX component is not available in the given version.  For instance, in this case, the shipping example for Microsoft Excel ActiveX components uses a previous version of the Excel ActiveX component library.  Most the time, Microsoft makes efforts to ensure that later versions of Excel are still compatible with previous version's ActiveX model, but in some cases, not everything works perfectly.  What I would recommend is that you rebuild the ActiveX libraries for Excel using your local ActiveX server.  A little explanation into what I mean: ActiveX is a protocol used to communicate between different programs.  The way that we can communicate with Excel is through ActiveX.  The library (shown at the bottom left of CVI in this example) for the Excel ActiveX server is representative of what functionality is made public from the Excel ActiveX server; that is, what Excel lets us have access to.  So, what Martin suggested and what I would suggest at this point is that you regenerate the library on your computer to ensure that the calls are compatible with your version of Excel (2003).  To do this, you can remove the current library from the bottom left and then select Tools -> Create ActiveX Controller.  Then select Microsoft Excel 11.0 Object Library (which is the ActiveX server version for Office 2003) and follow the on screen instructions.  This will regenerate the library to ensure compatibility with Office 2003.  You will have to change some of your code due to some version differences, but this might fix the issue that you are encountering.

Let us know if that does not fix your problem.

Thanks,

Andy McRorie
NI R&D
0 Kudos
Message 4 of 6
(5,107 Views)
Sorry, I didn't understand.
 
what do you mean: "you can remove the current library from the bottom left "
 
where execly is the "bottom left"?..
0 Kudos
Message 5 of 6
(5,076 Views)

Howdy sruly,

 

Andy is referring to the Library Tree at the bottom left hand corner of your Workspace view. In this Library Tree, you will have an Instruments folder where you can load your instrument drivers. 

 

The Microsoft Excel shipping examples that come with LabWindows/CVI are built using the Microsoft Word 2000 Automation Server (9.0).  The original setup you described was the scenario of using the Excel 9.0 object library with Excel 2003 (11.0). This is perfectly fine except that you will not have exposure to any additional objects, method, and properties that Microsoft came out with 2003.  For information about each object library and the available objects, methods, etc, refer to How to find and use Office object model documentation. What Andy and others mentioned, is to rebuild your instrument driver for Excel 2003. This will give you access to the latest object library for 2003.  When rebuilding Instruments drivers for use in existing shipping examples, make sure to use the same instrument prefix and the same Compatibility Options (for older programs, use "Per Server").  You will see these options when you use the wizard.

 

As far as your problem is concerned, the reason you are seeing the "no such interface supported" error could be for several reasons. However, in your case, you are not getting a reference to the Hyperlinks object first. I tested this out in the 9.0 object library and it works fine. So for example, you would say

 

 

error = CA_VariantSetCString (&VSubAddress, "Whatever");
error = CA_VariantSetCString (&VTextToDisplay, "NI's Website");
error = CA_VariantSetCString (&MyCellRangeV, "E15");

 

 

 

 

Excel_AppRange (ExcelAppHandle, NULL, MyCellRangeV, CA_DEFAULT_VAL, &ExcelRangeHandle);

 

 

 

error = Excel_WorksheetRange (ExcelWorksheetHandle, NULL, MyCellRangeV, CA_DEFAULT_VAL, &ExcelRangeHandle);   
 
error = Excel_GetProperty (ExcelWorksheetHandle, NULL, Excel_WorksheetHyperlinks, CAVT_OBJHANDLE, &HyperlinksObj);
 
 error = Excel_HyperlinksAdd (
HyperlinksObj, NULL, ExcelRangeHandle, "http://www.ni.com", VSubAddress,
        CA_DEFAULT_VAL, VTextToDisplay, &error);

 

 

 

 

This will get you up and running! 

 

 

 

 

 

Best Regards,

Jonathan N.
National Instruments
0 Kudos
Message 6 of 6
(5,053 Views)