Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default backing up file in directory

The user is asked to select a file:


Dim SaveDriveDir As String
SaveDriveDir = CurDir
ChDrive "C"
ChDir "C:\NREP\REL"
OFILE = Application.GetOpenFilename("NREP Relative Power Files,*.rel",
1, "Select One File To Open", , False)



Now I want to copy the file with a new name because I am going to
overwrite the existing file OFILE

copy OFILE & ".org"

How do I do this?

Lance

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default backing up file in directory

newName = Left(OFILE,len(OFILE)-4) & ".org"
name oFile as newName

--
Regards,
Tom Ogilvy


wrote in message
...
The user is asked to select a file:


Dim SaveDriveDir As String
SaveDriveDir = CurDir
ChDrive "C"
ChDir "C:\NREP\REL"
OFILE = Application.GetOpenFilename("NREP Relative Power Files,*.rel",
1, "Select One File To Open", , False)



Now I want to copy the file with a new name because I am going to
overwrite the existing file OFILE

copy OFILE & ".org"

How do I do this?

Lance



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default backing up file in directory

it seems that you'll need to remove the final 3 letters ie change the rel
extention to org

newname = left(OFILE,len(OFILE)-3) & "org)
FileCopy OFILE , newfile


--
Patrick Molloy
Microsoft Excel MVP
----------------------------------
wrote in message
...
The user is asked to select a file:


Dim SaveDriveDir As String
SaveDriveDir = CurDir
ChDrive "C"
ChDir "C:\NREP\REL"
OFILE = Application.GetOpenFilename("NREP Relative Power Files,*.rel",
1, "Select One File To Open", , False)



Now I want to copy the file with a new name because I am going to
overwrite the existing file OFILE

copy OFILE & ".org"

How do I do this?

Lance



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default backing up file in directory

This is renaming the file. I need to make a copy and still have
the original file:



OFILE = Application.GetOpenFilename("NREP Spectrum Files,*.fta", _
1, "Select One File To Open", , False)

'Backup Original Filename
newName = OFILE & ".org"
Name OFILE As newName


Workbooks.OpenText Filename:=OFILE, Origin:=437, _
StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array_
(Array(0, 1), Array(10 _
, 1), Array(19, 1), Array(28, 1), Array(37, 1), _
Array(46, 1), Array(55, 1), Array(64, 1), _
Array(73, 1), Array(82, 1), Array(91, 1), Array(100, 1), _
Array(109, 1), Array(118, 1), Array(127, 1), _
Array(136, 1),Array(145, 1), Array(154, 1), Array(163, 1)), _
TrailingMinusNumbers:=True



Tom Ogilvy wrote:

newName = Left(OFILE,len(OFILE)-4) & ".org"
name oFile as newName

--
Regards,
Tom Ogilvy


wrote in message
...

The user is asked to select a file:


Dim SaveDriveDir As String
SaveDriveDir = CurDir
ChDrive "C"
ChDir "C:\NREP\REL"
OFILE = Application.GetOpenFilename("NREP Relative Power Files,*.rel",
1, "Select One File To Open", , False)



Now I want to copy the file with a new name because I am going to
overwrite the existing file OFILE

copy OFILE & ".org"

How do I do this?

Lance







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default backing up file in directory

Why, you said you were going to overwrite it?

so use

newName = Left(OFILE,len(OFILE)-4) & ".org"
Filecopy oFile, newName


But oFile can't be open at the time.

--
Regards,
Tom Ogilvy


wrote in message
...
This is renaming the file. I need to make a copy and still have
the original file:



OFILE = Application.GetOpenFilename("NREP Spectrum Files,*.fta", _
1, "Select One File To Open", , False)

'Backup Original Filename
newName = OFILE & ".org"
Name OFILE As newName


Workbooks.OpenText Filename:=OFILE, Origin:=437, _
StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array_
(Array(0, 1), Array(10 _
, 1), Array(19, 1), Array(28, 1), Array(37, 1), _
Array(46, 1), Array(55, 1), Array(64, 1), _
Array(73, 1), Array(82, 1), Array(91, 1), Array(100, 1), _
Array(109, 1), Array(118, 1), Array(127, 1), _
Array(136, 1),Array(145, 1), Array(154, 1), Array(163, 1)), _
TrailingMinusNumbers:=True



Tom Ogilvy wrote:

newName = Left(OFILE,len(OFILE)-4) & ".org"
name oFile as newName

--
Regards,
Tom Ogilvy


wrote in message
...

The user is asked to select a file:


Dim SaveDriveDir As String
SaveDriveDir = CurDir
ChDrive "C"
ChDir "C:\NREP\REL"
OFILE = Application.GetOpenFilename("NREP Relative Power Files,*.rel",
1, "Select One File To Open", , False)



Now I want to copy the file with a new name because I am going to
overwrite the existing file OFILE

copy OFILE & ".org"

How do I do this?

Lance







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
Directory and File Detection Varne Excel Discussion (Misc queries) 3 November 18th 08 11:46 AM
file save error: the file or directory cannot be created dublg Excel Discussion (Misc queries) 1 September 25th 06 07:07 PM
Excel should let me sort the file directory when saving a file Beanee70 Excel Discussion (Misc queries) 0 March 14th 06 07:03 AM
Backing up Excel file AccessHelp Excel Discussion (Misc queries) 3 January 18th 06 11:59 PM
get path - save new file - same sub-directory as existing file tegger Excel Programming 2 October 21st 03 10:45 AM


All times are GMT +1. The time now is 12:08 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"