View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Hussain Hussain is offline
external usenet poster
 
Posts: 12
Default COPY A FILE OUTSIDE OF EXCEL!

Try the code below:

Option Explicit

Private Sub CopyFile()
Dim strSourcePath As String
Dim strSourceFile As String
Dim strTargetPath As String
Dim strTargetFile As String
Dim oFS As Object
Dim oFile As Object

strSourcePath = "C:\temp\"
strSourceFile = "myfile.ecw"
strTargetPath = ActiveWorkbook.Path & "\"
strTargetFile = Left(ActiveWorkbook.Name,
InStr(ActiveWorkbook.Name, ".") - 1) & ".ecw"
Set oFS = CreateObject("Scripting.FileSystemObject")
Set oFile = oFS.Copy(strTargetPath & strTargetFile)
Set oFile = Nothing
Set oFS = Nothing
End Sub