Read / Write Text Files From Visio Macro?

S

stephen.mason

Hi,

I have a file of coordinates which correspond to the vertices of line
segments. I'd like to read this into visio using a macro which would
then create the appropriate drawing. I have code to do the actual
drawing but am stuck trying to read the data. Visio help gives the
following example:

Sub OpenTextFileTest
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile("c:\testfile.txt",
ForAppending,TristateFalse)
f.Write "Hello world!"
f.Close
End Sub

However, this doesn't work and comes up with run time error '438'
Object doesn't support this property of method. Can anyone help?
 
S

stephen.mason

Never mind, going back to basics solved the problem:

Open "D:\TESTFILE.txt" For Input As #1

Input #1, A, B

Debug.Print A
Debug.Print B

Close #1

Works fine.
 
J

JuneTheSecond

Hi, Stephen.

Add reference To "Microsoft Scripting Runtime".
In VBA editor, click menu "Tools", "Set Reference",
amd find "Microsoft Scripting Runtime" in the list box.
Check "Microsoft Scripting Runtime" andpress "OK".
 
A

Al Edlund

It would help if we knew what the operating system and visio version is,
but, the first thing that comes to mind is scripting is not being referenced
in the the project. The second thing is that you are asking to append to a
file without first verifying that the file exists.
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