PC Review


Reply
Thread Tools Rate Thread

C++ Excel automate, add hyperlink

 
 
Rui Oliveira
Guest
Posts: n/a
 
      20th Feb 2008
C++ Excel automate, add hyperlink

How can I add a hyperlink in excel automation?

We have function “Hyperlink.Add”, but I don’t know what insert in first
argument.

LPDISPATCH Add(LPDISPATCH Anchor, LPCTSTR Address, const VARIANT&
SubAddress, const VARIANT& ScreenTip, const VARIANT& TextToDisplay);

Anyone have some sample code?

Thanks,
Rui

 
Reply With Quote
 
 
 
 
Birgit
Guest
Posts: n/a
 
      20th Feb 2008
Hi Rui,

Here is what I used recently from VBA

Set myHyperlink =
ActiveWorkbook.Worksheets("Inhoudsopgave").Hyperlinks.Add(Anchor:=myrange.Offset(i,
1).Range("A1"), Address:="", SubAddress:="'" & Worksheets(i).Name & "'!A1")
myHyperlink.TextToDisplay = "my Text here"

the argument anchor is a range (in my case I insert a number of hyperlinks
in a loop).
Sorry, this is no C++ but I'm sure you'll manage a LPDISPATCH to a
range-object.

The VBA-help of excel is an excellent source of information to the excel
object. There is very little C++ info around.

HTH,
Birgit

"Rui Oliveira" <(E-Mail Removed)> schreef in bericht
news:B726EB93-38E4-44B5-886C-(E-Mail Removed)...
> C++ Excel automate, add hyperlink
>
> How can I add a hyperlink in excel automation?
>
> We have function "Hyperlink.Add", but I don't know what insert in first
> argument.
>
> LPDISPATCH Add(LPDISPATCH Anchor, LPCTSTR Address, const VARIANT&
> SubAddress, const VARIANT& ScreenTip, const VARIANT& TextToDisplay);
>
> Anyone have some sample code?
>
> Thanks,
> Rui
>



 
Reply With Quote
 
Rui Oliveira
Guest
Posts: n/a
 
      20th Feb 2008
In vb I have the code. Thanks anyway.

In C++ I am trying something like:

icl_hyperlinks.Add(icl_oWksSheet.GetRange(COleVariant("A2"),
COleVariant("A2")), "c:\\test.txt", covOptional, covOptional,
COleVariant("test"));

But this way don't write any hyperlink.


"Birgit" wrote:

> Hi Rui,
>
> Here is what I used recently from VBA
>
> Set myHyperlink =
> ActiveWorkbook.Worksheets("Inhoudsopgave").Hyperlinks.Add(Anchor:=myrange.Offset(i,
> 1).Range("A1"), Address:="", SubAddress:="'" & Worksheets(i).Name & "'!A1")
> myHyperlink.TextToDisplay = "my Text here"
>
> the argument anchor is a range (in my case I insert a number of hyperlinks
> in a loop).
> Sorry, this is no C++ but I'm sure you'll manage a LPDISPATCH to a
> range-object.
>
> The VBA-help of excel is an excellent source of information to the excel
> object. There is very little C++ info around.
>
> HTH,
> Birgit
>
> "Rui Oliveira" <(E-Mail Removed)> schreef in bericht
> news:B726EB93-38E4-44B5-886C-(E-Mail Removed)...
> > C++ Excel automate, add hyperlink
> >
> > How can I add a hyperlink in excel automation?
> >
> > We have function "Hyperlink.Add", but I don't know what insert in first
> > argument.
> >
> > LPDISPATCH Add(LPDISPATCH Anchor, LPCTSTR Address, const VARIANT&
> > SubAddress, const VARIANT& ScreenTip, const VARIANT& TextToDisplay);
> >
> > Anyone have some sample code?
> >
> > Thanks,
> > Rui
> >

>
>
>

 
Reply With Quote
 
Rui Oliveira
Guest
Posts: n/a
 
      21st Feb 2008
I forgotten the GetHyperlinks


CString ls_cellPos;
ls_cellPos.Format("A%d", 3);
icl_hyperlinks = icl_oWksSheet.GetHyperlinks();
icl_hyperlinks.Add(icl_oWksSheet.GetRange(COleVariant(ls_cellPos),
COleVariant(ls_cellPos)), "c:\\test.txt", covOptional, covOptional,
COleVariant("test"));

Tks

"Rui Oliveira" wrote:

> C++ Excel automate, add hyperlink
>
> How can I add a hyperlink in excel automation?
>
> We have function “Hyperlink.Add”, but I don’t know what insert in first
> argument.
>
> LPDISPATCH Add(LPDISPATCH Anchor, LPCTSTR Address, const VARIANT&
> SubAddress, const VARIANT& ScreenTip, const VARIANT& TextToDisplay);
>
> Anyone have some sample code?
>
> Thanks,
> Rui
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use ADOX on Excel? How to automate Excel invocation on existing xls file from vbs? Siegfried Heintze Microsoft Excel Programming 0 7th Jun 2008 08:03 PM
Automate setting hyperlink location CJ Microsoft Access Form Coding 3 6th Mar 2008 09:26 PM
Would like to automate printing of Hyperlink files =?Utf-8?B?S2VtcGVy?= Microsoft Access VBA Modules 0 22nd Feb 2006 11:06 PM
automate hyperlink =?Utf-8?B?R0VPUkdJQQ==?= Microsoft Excel Misc 8 15th Aug 2005 10:18 PM
URGENT - NEED EXCEL PROGRAMMER - AUTOMATE THE TITLES IN MY EXCEL GRAPHS Marcello do Guzman Microsoft Excel Programming 1 6th Oct 2003 09:08 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:36 AM.