Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 376
  • Last Modified:

embedding excel cell into visio using OLE - using Visual basic

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?

0
pierre-alex
Asked:
pierre-alex
  • 2
1 Solution
 
Chris BottomleyCommented:
Would the worksheet be open ... and if not what path to locate it?

Can you confirm what you mean by a text object?

Chris
0
 
Chris BottomleyCommented:
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).

Chris
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
    xlWB.Close
    xlApp.Quit

Open in new window

0
 
pierre-alexAuthor Commented:
Works great, thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now