visio and excel

V

Vondre Daniel

Can you extract data from a spreadsheet and only extract the row or column
that you want instead of the entire spreadsheet with the highlighted data?
 
J

junethesecond

For example..

Option Explicit
Private appXl As Excel.Application
Private Book As Excel.Workbook

Sub XlOpen()
Set appXl = New Excel.Application
appXl.Visible = False
Set Book = appXl.Workbooks.Open _
("fullpath\filename.xls")
Debug.Print Book.Name
End Sub

Sub XlClose()
On Error Resume Next
Book.Close
Set appXl = Nothing
End Sub

Sub GetRangeValue()
Dim Sht As Excel.Worksheet
Dim Rng As Excel.Range
Dim Cel As Excel.Range
Dim PointX As Double, PointY As Double
Dim DeltaX As Double, DeltaY As Double
Dim I As Long
Dim Rect As Visio.Shape
Dim Wid As Double, Hei As Double
Wid = 1#
Hei = 0.3
PointX = 1#
PointY = 3#
DeltaX = Wid
DeltaY = 0
Set Sht = Book.Worksheets("Sheet1")
Set Rng = Sht.Range("A1", "B1")
For Each Cel In Rng
Debug.Print Cel.Value
Set Rect = ActivePage.DrawRectangle _
(PointX, PointY, PointX + Wid, PointY - Hei)
Rect.Text = Cel.Value
I = I + 1
PointX = PointX + I * DeltaX
PointY = PointY + I * DeltaY
Next
End Sub
 
V

Vondre Daniel

Thanks for your reply! I will check this code to see if it does what I need
and I'll get back in touch in a couple of days or so! Thanks again!!
 
V

Vondre Daniel

Can I use this code inside of Visio's vba application. Then place this subs
name in the shape's shapesheet, in the events section, to call the program?
 
J

junethesecond

Action section might be better,
because pop-up menus can be displayed
CallThis function, RUNADDON function
or RUNMACRO function are available
to call VBA subs.
Please, refer to the help documents
for details.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top