View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tony Seiscons Tony Seiscons is offline
external usenet poster
 
Posts: 9
Default References and Microsoft Scripting Runtime library

I know that I can create two file scripting objects with

Dim fsObject As Object, tsTextFile As Object

and then assign them with :

Set fsObject = CreateObject("Scripting.FileSystemObject")
Set tsTextFile = fsObject.OpenTextFile("C:\FolderName\TextFileName. txt",
1)

without setting a reference to the Microsoft Scripting Runtime Library.

If I create a reference to the library with Tools-References in the VB IDE I
can use

Dim fsObject as Scripting.FileSystemObject
Dim tsTextFile as Scripting.TextStream

and then

Set fsObject =New FileSystemObject
Set tsTextFile New tsOpenText("C:\FolderName\TextFileName.txt",
ForWriting, True)

I guess that this is early and late binding.

My question is this. I know that the first set of code will run without the
reference to the Microsoft Scripting Runtime Library set via the IDE but
will the second method? The second one is more useful to work with as the
context help becomes available with the reference set but if I give the
program to someone else I don't think it will it still work without the
reference being set. Can I set the reverence in code?

Tony