PDA

View Full Version : Solved: Dos Command in excel: "COPY " & file1 & " " & file2



andysuth
08-02-2007, 02:40 AM
I'm after a nice, neat, quick way of copying one file name to a file variant name.

Currently I'm using this:


Sub filecopier(verint As Integer)
Dim VFF As Long, vBody As String, filein As String, fileout As String
fileout = pathstring & verint & filestring & extension
filein = pathstring & 1001 & filestring & extension
' MsgBox ("copiedfile" & fileout)
VFF = FreeFile
Open filein For Binary As #VFF
vBody = Space$(LOF(VFF))
Get #VFF, , vBody
Close #VFF
Open fileout For Output As #VFF
Print #VFF, vBody
Close #VFF

End Sub


because I tried to use this:



Shell "copy " & pathstring & 1001 & filestring & extention & " " & pathstring & versionint & filestring & extention, vbMaximizedFocus


but it didn't like it.

All variables are plugged in before hand and the filenames check out when I do a msgbox with them in, it just doesn't like it.

The "Shell" method seems neater, but alas doesn't work.

Any clues?

Cheers!

-AS

andysuth
08-02-2007, 02:50 AM
Found it, typical of me, ask first, research later:


Sub copyfunc(verint As Integer)
Dim original As String, revision As String
original = pathstring & 1001 & filestring & extension
revision = pathstring & verint & filestring & extension
FileCopy original, revision
End Sub


originally from a post by M.D Mckillop on thread:
copying and Renaming files based on list in MS Word
http://www.vbaexpress.com/forum/showthread.php?t=13731

Thanks for reading. Sorry for wasting.