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 |
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 |
backing up file in directory
Lance,
Use FileCopy to copy the file. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com 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 |
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 |
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 |
backing up file in directory - SOLVED
Sorry for the extra post,
I send it before I grabbed new messages. Lance wrote: 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 |
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 |
All times are GMT +1. The time now is 09:07 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com