Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run a batch file from Excel
Good morning,
Is it possible to run a Dos batch file with code from Excel ? I save a file as a ".PRN" with excel and must then change it to ".DAT" and want to do this with my code & not have to go to the file right click and then "change name" and put in ".DAT". It needs to be ".DAT" so that it can be used in SAP. Thanks in advance. Tempy *** Sent via Developersdex http://www.developersdex.com *** |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run a batch file from Excel
You don't need DOS, you can do it from VBA
Name oldpathname As newpathname -- HTH Bob Phillips "Tempy" wrote in message ... Good morning, Is it possible to run a Dos batch file with code from Excel ? I save a file as a ".PRN" with excel and must then change it to ".DAT" and want to do this with my code & not have to go to the file right click and then "change name" and put in ".DAT". It needs to be ".DAT" so that it can be used in SAP. Thanks in advance. Tempy *** Sent via Developersdex http://www.developersdex.com *** |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run a batch file from Excel
Hello Bob,
I have tried using the code below but it does not work ? Could you please heeeelp ? The code runs, but does not change the ".PRN to ".DAT" ChDir "\\zapad01\sapinter" ActiveWorkbook.SaveAs Filename:="\\zapad01\sapinter\GPS" & res & ".PRN", _ FileFormat:=xlTextPrinter, CreateBackup:=False ActiveWindow.Close OldName = "\\zapad01\sapinter\GPS" & res & ".PRN": NewName = _ "\\zapad01\sapinter\GPS" & res & ".DAT" Tempy *** Sent via Developersdex http://www.developersdex.com *** |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run a batch file from Excel
Hi Tempy,
Try this ChDir "\\zapad01\sapinter" ActiveWorkbook.SaveAs Filename:="\\zapad01\sapinter\GPS" & res & ".PRN", _ FileFormat:=xlTextPrinter, CreateBackup:=False ActiveWindow.Close OldName = Activeworkbook.path & "\"& res & ".PRN" NewName = Activeworkbook.path & "\"& res & ".DAT" Name Oldname As Newname -- HTH Bob Phillips "Tempy" wrote in message ... Hello Bob, I have tried using the code below but it does not work ? Could you please heeeelp ? The code runs, but does not change the ".PRN to ".DAT" ChDir "\\zapad01\sapinter" ActiveWorkbook.SaveAs Filename:="\\zapad01\sapinter\GPS" & res & ".PRN", _ FileFormat:=xlTextPrinter, CreateBackup:=False ActiveWindow.Close OldName = "\\zapad01\sapinter\GPS" & res & ".PRN": NewName = _ "\\zapad01\sapinter\GPS" & res & ".DAT" Tempy *** Sent via Developersdex http://www.developersdex.com *** |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run a batch file from Excel
Where is the line of code that does
ActiveWorkbook.SaveAs Filename:="\\zapad01\sapinter\GPS" _ & res & ".PRN", _ FileFormat:=xlTextPrinter, CreateBackup:=False ActiveWindow.Close OldName = "\\zapad01\sapinter\GPS" & res & ".PRN" NewName = "\\zapad01\sapinter\GPS" & res & ".DAT" name Oldname to NewName anyway, just naming it DAT from the start worked for me: ActiveWorkbook.SaveAs Filename:="\\zapad01\sapinter\GPS" _ & res & ".DAT", _ FileFormat:=xlTextPrinter, CreateBackup:=False -- Regards, Tom Ogilvy "Tempy" wrote in message ... Hello Bob, I have tried using the code below but it does not work ? Could you please heeeelp ? The code runs, but does not change the ".PRN to ".DAT" ChDir "\\zapad01\sapinter" ActiveWorkbook.SaveAs Filename:="\\zapad01\sapinter\GPS" & res & ".PRN", _ FileFormat:=xlTextPrinter, CreateBackup:=False ActiveWindow.Close OldName = "\\zapad01\sapinter\GPS" & res & ".PRN": NewName = _ "\\zapad01\sapinter\GPS" & res & ".DAT" Tempy *** Sent via Developersdex http://www.developersdex.com *** |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run a batch file from Excel
Hi Bob,
Thanks for the reply, i tried it and i get an error when it gets to Name Oldname As Newname - the error is File not found Runtime error 53 ChDir "\\zapad01\sapinter" ActiveWorkbook.SaveAs Filename:="\\zapad01\sapinter\GPS" & res & ".PRN", _ FileFormat:=xlTextPrinter Oldname = ActiveWorkbook.Path & "\\zapad01\sapinter\GPS" & res & ".PRN" Newname = ActiveWorkbook.Path & "\\zapad01\sapinter\GPS" & res & ".DAT" Name Oldname As Newname Tempy *** Sent via Developersdex http://www.developersdex.com *** |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run a batch file from Excel
Hi Tom,
I have also succesfully saved it as a ".DAT" file, but when i opened it, it is just full of Asxi code ?? Tempy *** Sent via Developersdex http://www.developersdex.com *** |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run a batch file from Excel
Hi Again Tom,
I have just changed the code to yours and it works great. thank you both for your perseverance and great help. Thank you Tempy *** Sent via Developersdex http://www.developersdex.com *** |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can excel run a batch file? | Excel Discussion (Misc queries) | |||
Excel from Batch File Problem | Excel Discussion (Misc queries) | |||
Excel to Run a Batch File?!? | New Users to Excel | |||
Create a batch file from a number of Excel File | Excel Programming | |||
Running a batch file from Excel VBA | Excel Programming |