Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default FileSystemObject

I am trying to copy a file within an Excel application
using VBA 6.0. 'Help' says to use a FileSystemObject
which has a Move method. But the VBA development
environment will not let me Dim a variable as a
FileSystemObject. Is there a library that I need to
activate? Or is there a workaround with older commands?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default FileSystemObject

There are two methods really: Early binding or Late binding.

Early bind:
From the VB Editor menu:
Tools | References
Choose Microsoft Scripting Runtime

Then you can dim a variable as Scripting.FileSystemObject
eg.
Sub test()
Dim fso As Scripting.FileSystemObject
End Sub



In practise, it's sometimes a good idea to late-bind:
(no need to add the Microsoft Scripting Runtime reference)

eg.
Sub test()
Dim fso As Object

Set fso = CreateObject("Scripting.FileSystemObject")
End Sub


Someone may have a pointer to an article discussing the merits of either - I
don't have one handy right now.


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"lol" wrote in message
...
I am trying to copy a file within an Excel application
using VBA 6.0. 'Help' says to use a FileSystemObject
which has a Move method. But the VBA development
environment will not let me Dim a variable as a
FileSystemObject. Is there a library that I need to
activate? Or is there a workaround with older commands?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default FileSystemObject

You could add a reference to the
Microsoft scripting runtime

but you may not need it if you take a look at the FileCopy statement first

lol wrote:

I am trying to copy a file within an Excel application
using VBA 6.0. 'Help' says to use a FileSystemObject
which has a Move method. But the VBA development
environment will not let me Dim a variable as a
FileSystemObject. Is there a library that I need to
activate? Or is there a workaround with older commands?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Scripting.FileSystemObject Leif Rasmussen Excel Discussion (Misc queries) 1 January 12th 05 11:21 PM
Using FileSystemObject to get File tod Excel Programming 2 January 9th 04 04:30 PM
Scripting.FileSystemObject LAN Mirom Excel Programming 0 January 3rd 04 06:30 AM
Creating FileSystemObject Kirk[_2_] Excel Programming 2 September 9th 03 10:24 PM
Help with FileSystemObject? Ed[_9_] Excel Programming 2 August 5th 03 12:08 AM


All times are GMT +1. The time now is 07:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"