backing up file in directory

  • Thread starter Thread starter lance-news
  • Start date Start date
L

lance-news

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
 
Lance,

Use FileCopy to copy the file.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com (e-mail address removed)
 
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
 
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
 
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.
 
Back
Top