Solved

name,view,copy and rename seq files

Posted on 1998-07-27
5
217 Views
Last Modified: 2010-05-03
my file is called xzt.seq. It is on the C drive. How do I, with a command button:
1) rename it to (Jan, feb, mar,......dec.seq) to be stored on A drive. I know I will need 'IF EXIST' for this. If jan,feb,mar are on the A drive I need the code for apr.
2.) now I need to view all the files on A drive,( jan.seq thru dec.seq ) with a commmand button, select one, load it to C drive and rename it to zxt.seq so I can run that months data. I anm using vb4-32bit
0
Comment
Question by:hjaycox
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Author Comment

by:hjaycox
ID: 1466868
Edited text of question
0
 
LVL 9

Accepted Solution

by:
Dalin earned 500 total points
ID: 1466869
hjaycox,
Try this, let me know if you have questions.
Regards
Dalin

'Declare
'In General Declaration Area:

Dim FileArray(1 to 12) as String

' in Form load
FileArray(1)= "A:\Jan.seq"
FileArray(2)="A:\Feb.Seq"
.
FileArray(12) = "A:\Dec.Seq"

'Drop a command button, name it cmdFromCtoA, in the click event,
add the code

Dim i as Integer
Dim lString as String
For i = 1 to 12
    ' Try to see if the file exist
    lString = Dir(fileArray(i))
    If lString = ""
       ' This is the file not in
       lString = fileArray(i)
       Exit for
       End IF
   Next i
FileCopy "C:\xzt.seq" lString

Drop a commanDialog Box, name it comdial, and drop a command button, name it cmdFromAtoC, add the code:

Dim lString as String

On Error GoTo FileErrorHandler

'Get a file name From the User
comdial.DialogTitle = Title
comdial.Filter = "All Files|*.*"
comdial.Action = 2
lString = comdial.filename


FileCopy lString "C:\xzt.seq"

Exit Sub

FileErrorHandler:
Err.Clear
'Resume Next or handle your error


0
 
LVL 9

Expert Comment

by:Dalin
ID: 1466870
hjayCox,
You may also want to check if xzt.seq exist when you copy from a to C:  You can add:

Dim lCFile as String
lCFile = Dir("C:\xzt.seq")
If cFile > "" then
   'Delete it? Use Kill
   ' Kill "C:\xzt.seq"
   End If

Regards
Dalin

0
 

Author Comment

by:hjaycox
ID: 1466871
things work great EXCEPT. I cannot copy from C to A.
FileCopy "C:\xzt.seq" lString  is the problem area. [I think]
I believe the format for filecopy [is] "c:\xyz.seq", "a:\abc.seq"
I do not understand why it will work from a to c and not c to a
 For a to c I have had to modify your code from:
comdial.DialogTitle = Title
comdial.Filter = "All Files|*.*"
comdial.Action = 2        'save as
lString = comdial.filename
to                 :comdial.DialogTitle = Title
                    comdial.Filter = "All Files|*.*"
                     comdial.Action = 1      ' open
                    lString = comdial.filename
as comdial.action = 2 opened the diag box as SAVE AS while
#1 = open
I then had to ADD
comdial.Action = 6    'copy
lString = comdial.filename
filecopy IString "c:\xzt.seq" and it works, but in c to a filecopy "c:\xzt.seq" IString nothing happens, AND I get NO error flags.
There is no fileErrorHandler in the program at this point.
HELP !!!!!!!
0
 

Author Comment

by:hjaycox
ID: 1466872
Dalin.... forget it.... I HAD A BRAIN FART...../.
EVERYTHING WORKS FINE !!!!!!!!!!!
thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month6 days, 5 hours left to enroll

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question