Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default COPY A FILE OUTSIDE OF EXCEL!

Hi,

I have a file called "E:\ENGINEERING FOLDER\001-Ready\Template.ecw" I would
like to copy this file to the same directory that my current excel file is
stored and running, after that I would like to rename this new file to "
current excel file name.ecw " , is this possible?
can anyone please help me to create this VBA?

Thanks in advance.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default COPY A FILE OUTSIDE OF EXCEL!

With ThisWorkbook
Name "E:\ENGINEERING FOLDER\001-Ready\Template.ecw" As .Path & "\" &
Left(.Name, Len(.Name) - 4) & ".ecw"
End With

NickHK

"2007-User" wrote in message
...
Hi,

I have a file called "E:\ENGINEERING FOLDER\001-Ready\Template.ecw" I

would
like to copy this file to the same directory that my current excel file is
stored and running, after that I would like to rename this new file to "
current excel file name.ecw " , is this possible?
can anyone please help me to create this VBA?

Thanks in advance.




  #3   Report Post  
Posted to microsoft.public.excel.programming
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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default COPY A FILE OUTSIDE OF EXCEL!

Nick

I didn't know about the "Name" command in VBA.

Neat solution.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default COPY A FILE OUTSIDE OF EXCEL!

Hi 2007-user,
try this one, maybe solve ur problem:

Sub CopyFile()
Dim currentfilename

currentfilename = mid(ActiveWorkbook.Name,1,len(ActiveWorkbook)-4)
' _
'if your ActiveWorkbook is has path, to prevent doubled file extention.
'currentfilename =ActiveWorkbook 'if ur ActiveWorkbook not saved

FileCopy "E:\ENGINEERING FOLDER\001-Ready\Template.ecw", _
"E:\ENGINEERING FOLDER\001-Ready\" & currentfilename & ".ecw"

End Sub

Regards,

Halim



2007-User menuliskan:
Hi,

I have a file called "E:\ENGINEERING FOLDER\001-Ready\Template.ecw" I would
like to copy this file to the same directory that my current excel file is
stored and running, after that I would like to rename this new file to "
current excel file name.ecw " , is this possible?
can anyone please help me to create this VBA?

Thanks in advance.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default COPY A FILE OUTSIDE OF EXCEL!

Thanks a lot for all of your responses, I'll try those solutions and let you
know bout the results...




wrote in message
ups.com...
Hi 2007-user,
try this one, maybe solve ur problem:

Sub CopyFile()
Dim currentfilename

currentfilename = mid(ActiveWorkbook.Name,1,len(ActiveWorkbook)-4)
' _
'if your ActiveWorkbook is has path, to prevent doubled file extention.
'currentfilename =ActiveWorkbook 'if ur ActiveWorkbook not saved

FileCopy "E:\ENGINEERING FOLDER\001-Ready\Template.ecw", _
"E:\ENGINEERING FOLDER\001-Ready\" & currentfilename & ".ecw"

End Sub

Regards,

Halim



2007-User menuliskan:
Hi,

I have a file called "E:\ENGINEERING FOLDER\001-Ready\Template.ecw" I
would
like to copy this file to the same directory that my current excel file
is
stored and running, after that I would like to rename this new file to "
current excel file name.ecw " , is this possible?
can anyone please help me to create this VBA?

Thanks in advance.




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
How to copy 2007 excel file formula results into a 2003 Excel file Nuria Alba de Luz Excel Discussion (Misc queries) 2 July 10th 09 01:48 PM
How do I copy a excel file into a InDesign file correctly? cfb Excel Discussion (Misc queries) 2 June 14th 07 10:08 PM
copy multiple worksheets of a workbook, and paste onto a Word document ( either create new doc file or paste onto an existing file.) I need this done by VBA, Excel Macro Steven Excel Programming 1 October 17th 05 08:56 AM
EXCEL FILE a copy/a copy/a copy ....filename ve New Users to Excel 1 September 29th 05 09:12 PM
VBA Macro to copy an column from one Excel file into another file Sam Excel Programming 4 July 3rd 05 03:36 AM


All times are GMT +1. The time now is 11:28 PM.

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"