+ Reply to Thread
Results 1 to 5 of 5

Ole Links (C++)

  1. #1
    Registered User
    Join Date
    02-28-2006
    Posts
    2

    Ole Links (C++)

    I don't know if this is the proper forum for asking a C++ Excel programming question, but here goes.

    My application has an _Application, _Workbook, and Workbooks classes all derived from COleDispatchDriver that were added from Excel's type library. The two methods I'm interested in using right now are:

    void ChangeLink(LPCTSTR Name, LPCTSTR NewName, long Type);
    VARIANT LinkSources(const VARIANT& Type);

    That are declared in the _Workbook class. I'd like to iterate through all the client links Excel is holding onto and change the filename they're pointing to, however I can't find any good documentation or samples on how to use these or any other methods from a C++ perspective. Could anyone direct me to such documentation or provide some samples?

  2. #2
    NickHK
    Guest

    Re: Ole Links (C++)

    sjc,
    The Excel VBA Help has examples of both of these, in VB of course, but
    should be relatively straight forward to translate into C++ for someone who
    knows that beast.

    NickHK

    "sjc" <[email protected]> wrote in message
    news:[email protected]...
    >
    > I don't know if this is the proper forum for asking a C++ Excel
    > programming question, but here goes.
    >
    > My application has an _Application, _Workbook, and Workbooks classes
    > all derived from COleDispatchDriver that were added from Excel's type
    > library. The two methods I'm interested in using right now are:
    >
    > void ChangeLink(LPCTSTR Name, LPCTSTR NewName, long Type);
    > VARIANT LinkSources(const VARIANT& Type);
    >
    > That are declared in the _Workbook class. I'd like to iterate through
    > all the client links Excel is holding onto and change the filename
    > they're pointing to, however I can't find any good documentation or
    > samples on how to use these or any other methods from a C++
    > perspective. Could anyone direct me to such documentation or provide
    > some samples?
    >
    >
    > --
    > sjc
    > ------------------------------------------------------------------------
    > sjc's Profile:

    http://www.excelforum.com/member.php...o&userid=32001
    > View this thread: http://www.excelforum.com/showthread...hreadid=517354
    >




  3. #3
    Registered User
    Join Date
    02-28-2006
    Posts
    2
    I've seen samples in VB, like this:

    Please Login or Register  to view this content.
    In C++, the parameter to LinkSources is a "const VARIANT&". Well what fields in the variant should be populated? And where is xlExcelLinks defined in my case? There's no good documentation for that.

  4. #4
    NickHK
    Guest

    Re: Ole Links (C++)

    sjc,
    LinkSources returns an array of strings or Empty.
    xlExcelLinks is defined in Excel as a member of the XlLink enum:
    Enum XlLink
    xlExcelLinks = 1
    xlOLELinks = 2
    xlPublishers = 5
    xlSubscribers = 6
    End Enum

    NickHK


    "sjc" <[email protected]> wrote in message
    news:[email protected]...
    >
    > I've seen samples in VB, like this:
    >
    >
    > Code:
    > --------------------
    >
    > Sub ListLinks()
    > Dim aLinks As Variant
    > aLinks = ActiveWorkbook.LinkSources(xlExcelLinks)
    > If Not IsEmpty(aLinks) Then
    > Sheets.Add
    > For i = 1 To UBound(aLinks)
    > Cells(i, 1).Value = aLinks(i)
    > Next i
    > End If
    > End Sub
    >
    > --------------------
    >
    >
    > In C++, the parameter to LinkSources is a "const VARIANT&". Well what
    > fields in the variant should be populated? And where is xlExcelLinks
    > defined in my case? There's no good documentation for that.
    >
    >
    > --
    > sjc
    > ------------------------------------------------------------------------
    > sjc's Profile:

    http://www.excelforum.com/member.php...o&userid=32001
    > View this thread: http://www.excelforum.com/showthread...hreadid=517354
    >




  5. #5
    Registered User
    Join Date
    09-12-2006
    Posts
    6
    Does anybody know whether it is possible to write code that finds links of links.

    You can use linksources to find all the sources in a workbook, but what about finding the relevant sources of the sources in the original workbook. ie If the active workbook has spreadsheet links and if you followed that audit trail and go to the linked cell, that cell has a link to another workbook. How could you write code that finds these "secondary" links?

    A possible problem that can arise is when the process becomes cylical. e.g If we have two spreadsheets (A and B), and they are both linked to each other, how would we write code that stops the programmind running forever and how can that be displayed on the output?

    Any responses are welcome.
    Thanks
    Last edited by Harmeet13; 09-12-2006 at 06:31 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1