|
-
Sep 3rd, 2011, 08:34 PM
#1
[RESOLVED] copy files need help doesnt work!!
i'm trying to rename files or copy and then kill the first file my code i wrote is
i tried
Private Sub Command6_Click()
Dim StrFile As String
Dim StrFile2 As String
Dim F1 As String
Dim F2 As String
F1 = Chr(34) & Text1.Text & " \ " & List3.Text & Chr(34)
F2 = Chr(34) & Text1.Text & "\" & List2.Text & ".pacw" & Chr(34)
StrFile = Replace(F1, Chr(34), "")
StrFile2 = Replace(F2, Chr(34), "")
FileCopy F1, F2
Kill F1
End Sub
and then tried
Private Sub Command6_Click()
Dim F1 As String
Dim F2 As String
F1 = Chr(34) & Text1.Text & " \ " & List3.Text & Chr(34)
F2 = Chr(34) & Text1.Text & "\" & List2.Text & ".pacw" & Chr(34)
FileCopy F1, F2
Kill F1
End Sub
for some reason it only work if i write it myself
like
filecopy "c:\test.txt", "c:\textreplace.txt"
kill "c:\test.txt"
if there is a way to just rename it be alot better but it doesnt matter either way help please, thank you!
-
Sep 3rd, 2011, 08:36 PM
#2
Re: copy files need help doesnt work!!
sorry i tried this to
Private Sub Command6_Click()
Dim StrFile As String
Dim StrFile2 As String
Dim F1 As String
Dim F2 As String
F1 = Text1.Text & " \ " & List3.Text
F2 = Text1.Text & "\" & List2.Text & ".pacw"
FileCopy F1, F2
Kill F1
End Sub
-
Sep 3rd, 2011, 10:03 PM
#3
Re: copy files need help doesnt work!!
there is space before and after the \
Code:
F1 = Text1.Text & " \ " & List3.Text
-
Sep 3rd, 2011, 10:11 PM
#4
Re: copy files need help doesnt work!!
yes i noticed and fixed it still doenst work
-
Sep 3rd, 2011, 10:16 PM
#5
Re: copy files need help doesnt work!!
Code:
Name oldpathname As newpathname
-
Sep 3rd, 2011, 10:17 PM
#6
Re: copy files need help doesnt work!!
i tried this...
FileCopy Text1.Text & "\" & List3.Text, Text1.Text & "\" & List2.Text & ".pacw"
Kill Text1.Text & "\" & List3.Text
it highlights FileCopy Text1.Text & "\" & List3.Text, Text1.Text & "\" & List2.Text & ".pacw"
and in debug tells me run-time error : 52 bad file name of number
and when i highlight Text1.Text & "\" & List3.Text and put my mouse over it it give me the right path everything is good but it doesnt work...
-
Sep 3rd, 2011, 10:20 PM
#7
Re: copy files need help doesnt work!!
i tried
Name Text1.Text & "\" & List3.Text As Text1.Text & "\" & List2.Text & ".pacw"
run-time error 5 invalid procedure or argument
-
Sep 3rd, 2011, 10:27 PM
#8
Re: copy files need help doesnt work!!
can u copy the file manually and directly type the path like this?
Code:
FileCopy "D:\test.txt", "D:\test.pacw"
if yes then i suspect list3.text, it may not hav the extension name, and list2.text shudnt hav extension name, check these things.
-
Sep 3rd, 2011, 10:46 PM
#9
Re: copy files need help doesnt work!!
yes if i write it like that it works
filecopy "c:\test.txt", "c"\test.pacw"
ive been checking everything but like i said when im in debug mode i highlight my ff1 and ff2 and it gives me my right path which is ff1 "C:\PacWest\Max\upper1.pacw" and other one is ff2 "C:\PacWest\Max\Upper.pacw" i want to rename the upper1.pacw to upper.pacw but i dont want to put it as
name "C:\PacWest\Max\upper1.pacw", "C:\PacWest\Max\Upper.pacw"
I would like to name it with
name ff1, ff2
i use dim ff1 as string, dim ff2 as string and
ff1 = "C:\PacWest\Max\Upper1.pacw"
ff2 = "C:\PacWest\Max\Upper.pacw"
Private Sub Command6_Click()
Dim StrFile As String
Dim StrFile2 As String
Dim Ff1 As String
Dim Ff2 As String
Ff1 = "C:\PacWest\Max\Upper1.pacw"
Ff2 = "C:\PacWest\Max\Upper.pacw"
FileCopy Ff1, Ff2
End Sub
this code works
your probably right its in my list i guess i can check in them but i'm sure it right
-
Sep 3rd, 2011, 11:08 PM
#10
Re: copy files need help doesnt work!!
can u show me what is in textbox and listbox? dont use the " before and after the string in textbox and listbox.
-
Sep 3rd, 2011, 11:11 PM
#11
Re: copy files need help doesnt work!!
i found my problem it was in list2.text because when i open a file i make it write in lines
1
2
3
so i use
MyArr = Split(Text2.Text, vbCrLf)
For i = 0 To UBound(MyArr)
it add a space "vbcrlf" so i removed the vbcrlf
Private Sub Command6_Click()
Dim StrFile2 As String
Dim Ff1 As String
Dim Ff2 As String
Ff1 = "C:\PacWest\Max\Upper1.pacw" 'Text1.Text & "\" & List3.Text
Ff2 = "C:\PacWest\Max\Upper.pacw" 'Text1.Text & "\" & List2.Text & ".pacw"
StrFile2 = Replace(Ff2, vbCrLf, "")
Name Ff1 As StrFile2
End Sub
thanks for your help guys
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|