Visio -> Project

D

dlauer

I am completely new to Visio VBA, though I have a lot of experience
with VBA in excel. Here's what I would like to do, any assistance would
be appreciated:

I have several text boxes in my visio diagram. I would like to count
the number of lines in each one. If possible, I would also like to take
this information and somehow build a Microsoft Project .mpp file with
it. If this is impossible/too difficult, I could always just have the
thing MsgBox me the information and I can do it manually.

Thanks for any help!

Dave
 
L

LarryF

You can get to a shape's text through its Text property, as in
Page.Shapes("ShapeName").Text. When you say 'count the number of
lines', I assume you mean the lines of text, and I also assume you mean
the lines separated with vbLFs, not lines created by word wrapping at
spaces between words because the text box is too skinny for a whole
line of text. So, to count the lines of text, you can use InStr() to
count the number of vbLfs, as in:

Dim iStart As Integer, iEnd As Integer, iLines as Integer
Dim sText as string
sText = <shape>.Text

iStart = 1
Do
iEnd = InStr(iStart, sText, vbLf)
If iEnd > 0 Then
'Found a line break.
iLines = iLines + 1
iStart = iEnd + 1
End If
Loop While iEnd > 0

Now you want to get it into Project. I'm sure Project has an automation
interface, like Visio and Excel, but I don't know anything about it. So
you have to learn to use that automation interface to build a new .mmp
file. Or, if you want to avoid using Project's automation interface, I
think Project can import data from Excel. If you can figure out how it
imports, your Visio program could write the results to Excel, then you
could import into Project.

Good luck.
 
A

Al Edlund

if you check out the visio sdk there is a sample program (treeview) that
demonstrates linking visio to project.
al
 

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