Hi All,
I have two fixed width text files which I have created from an excel workbook and I'm trying to append one to another and output the result to a third text file. I've been using the shell to do it as it seemed to be the simplest way. The following works fine:
OutputFolderName = "C:\"
ShellStr = "command.com /c Copy " & OutputFolderName & "TypeH.txt + " & OutputFolderName & "Type1.txt " & OutputFolderName & "NewType1.txt"
Shell ShellStr, vbHide
The shell command works out as: command.com /c Copy C:\TypeH.txt + C:\Type1.txt C:\NewType1.txt
This works perfectly fine, the problem occurs when I try to change the variable OutputFolderName to a networked drive,
eg G:\VG\State Tax\Dev\XX01.12.SP\ or even G:\VG
I have included extra quotes around the directory names, eg.
Qu = Chr(34) 'Double Quotes
OutputFolderName = “G:\VG\State Tax\Dev\XX01.12.SP\”
ShellStr = "command.com /c Copy " & Qu & OutputFolderName & Qu & "TypeH.txt + " & Qu & OutputFolderName & Qu & "Type1.txt " & _
Qu & OutputFolderName & Qu & "NewType1.txt"
Shell ShellStr, vbHide
- the copy commands work fine when I test them using a dos prompt but I can’t get them to work in VBA – I get the error “Invalid procedure call or argument (Error 5)
I’m using excel 2003 and Windows XP.
Regards,
Lea.
I have two fixed width text files which I have created from an excel workbook and I'm trying to append one to another and output the result to a third text file. I've been using the shell to do it as it seemed to be the simplest way. The following works fine:
OutputFolderName = "C:\"
ShellStr = "command.com /c Copy " & OutputFolderName & "TypeH.txt + " & OutputFolderName & "Type1.txt " & OutputFolderName & "NewType1.txt"
Shell ShellStr, vbHide
The shell command works out as: command.com /c Copy C:\TypeH.txt + C:\Type1.txt C:\NewType1.txt
This works perfectly fine, the problem occurs when I try to change the variable OutputFolderName to a networked drive,
eg G:\VG\State Tax\Dev\XX01.12.SP\ or even G:\VG
I have included extra quotes around the directory names, eg.
Qu = Chr(34) 'Double Quotes
OutputFolderName = “G:\VG\State Tax\Dev\XX01.12.SP\”
ShellStr = "command.com /c Copy " & Qu & OutputFolderName & Qu & "TypeH.txt + " & Qu & OutputFolderName & Qu & "Type1.txt " & _
Qu & OutputFolderName & Qu & "NewType1.txt"
Shell ShellStr, vbHide
- the copy commands work fine when I test them using a dos prompt but I can’t get them to work in VBA – I get the error “Invalid procedure call or argument (Error 5)
I’m using excel 2003 and Windows XP.
Regards,
Lea.