embedding excel cell into visio using OLE - using Visual basic

Posted on 2011-10-21
Last Modified: 2012-05-12
In  Visio visual basics, how do I call let's say cell A5 of worksheet "test.xls" and display it as the data of a text object?

Question by:pierre-alex
    LVL 59

    Expert Comment

    by:Chris Bottomley
    Would the worksheet be open ... and if not what path to locate it?

    Can you confirm what you mean by a text object?

    LVL 59

    Accepted Solution

    For example:

    Assuming xl is not open or the workbook can be opened in a new instance of excel with the output going to a text box, (the first shape but name can alse be used as per the commented out line).

    Dim xlApp As Object
    Dim xlWB As Object
    Dim xlSh As Object
        Set xlApp = CreateObject("excel.application")
        Set xlWB = xlApp.workbooks.Open("c:\deleteme\textfile.xls")
        Set xlSh = xlWB.sheets(1)
        Application.ActiveDocument.Pages(1).Shapes(1).Characters.Text = xlSh.Range("a5").Text
    '    Application.ActiveDocument.Pages(1).Shapes("Doris").Characters.Text = xlSh.Range("a5").Text

    Open in new window


    Author Closing Comment

    Works great, thanks

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
    This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now