Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On 8/16/2010 3:23 PM, Chris wrote:
On Mon, 16 Aug 2010 01:06:52 +0100, "RB Smissaert" wrote: RetVal = Shell("G:\From G Data\Data Files& Test Programs\Work Data\zipbatch.bat", 1) Is this a valid file path. I am thinking of the& here. Otherwise try with code like this: Thanks very much for taking the trouble to reply. Actually it turns out that the '&' *was* causing the failure. I tried on a folder with no ampersand in its name, and everything worked perfectly. I never expected that, as the batch file itself was quite happy with the ampersand in the path name. This shouldn't be a problem in practice, as I don't think any of the folders I will actually be using (as opposed to the one I tried for testing - bad choice!!) have ampersands in their name. But, is there a way of using a path with an ampersand in it? Anyway, thanks again for your help - it was invaluable! Chris. I hope nobody minds me jumping in, you might try using VB to change to the folder where the batch file reside, then running it, maybe something like this (but I don't know about the other arguments to ExecCmd so make sure you use values you like): CurDir "C:\From G Data\Data Files & Test Programs\Work Data\" ExecCmd "zipbatch.bat", 15, True, "" |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On 8/16/2010 4:45 PM, Mike S wrote:
On 8/16/2010 3:23 PM, Chris wrote: On Mon, 16 Aug 2010 01:06:52 +0100, "RB Smissaert" wrote: RetVal = Shell("G:\From G Data\Data Files& Test Programs\Work Data\zipbatch.bat", 1) Is this a valid file path. I am thinking of the& here. Otherwise try with code like this: Thanks very much for taking the trouble to reply. Actually it turns out that the '&' *was* causing the failure. I tried on a folder with no ampersand in its name, and everything worked perfectly. I never expected that, as the batch file itself was quite happy with the ampersand in the path name. This shouldn't be a problem in practice, as I don't think any of the folders I will actually be using (as opposed to the one I tried for testing - bad choice!!) have ampersands in their name. But, is there a way of using a path with an ampersand in it? Anyway, thanks again for your help - it was invaluable! Chris. I hope nobody minds me jumping in, you might try using VB to change to the folder where the batch file reside, then running it, maybe something like this (but I don't know about the other arguments to ExecCmd so make sure you use values you like): CurDir "C:\From G Data\Data Files & Test Programs\Work Data\" ExecCmd "zipbatch.bat", 15, True, "" Apologies, CurDir works in VB6 but not VBA I test this in an Excel 2000 macro and it worked, so I think this may work for you: Public Sub doin() Dim path As String ChDir "C:\From G Data\Data Files & Test Programs\Work Data" path = CurDir MsgBox path End Sub ChDir "G:\From G Data\Data Files & Test Programs\Work Data\" ExecCmd "zipbatch.bat", 15, True, "" Sorry for not testing before posting, I need to remember that there are some differences between VB6 and VBA. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Mon, 16 Aug 2010 19:20:02 -0700, Mike S wrote:
Apologies, CurDir works in VB6 but not VBA I test this in an Excel 2000 macro and it worked, so I think this may work for you: Public Sub doin() Dim path As String ChDir "C:\From G Data\Data Files & Test Programs\Work Data" path = CurDir MsgBox path End Sub ChDir "G:\From G Data\Data Files & Test Programs\Work Data\" ExecCmd "zipbatch.bat", 15, True, "" Sorry for not testing before posting, I need to remember that there are some differences between VB6 and VBA. Mike - thanks for your trouble. I did say you were dealing with a novice, and, to be honest, simply not using ampersands in folder names is a much simpler solution for me! But I do appreciate your time. Thanks again. Chris. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
batch file to ftp code not running - please help! | Excel Programming | |||
Running a Batch file from VBA | Excel Programming | |||
running a batch file | Excel Programming | |||
Running a batch file from VB | Excel Programming | |||
Running a batch file from Excel VBA | Excel Programming |