Running a .bat file with spaces in the path.

I am trying to run a .bat file from a macro. The shell command works okay most of the time - but I cannot seem to make it work if there is a space in the path. (So, running C:\Apps\BFIle.bat works, but not C:\My Apps\BFile.bat)

As the .bat file I want to run will change, I want to enter the path in a cell, and then run the macro with a button. This means simply enteing the path in double quotation marks in the Shell command will not work.

BFile = Range("A2").Value
i = Shell (BFile, 1)

Any ideas?
0
Luffs (2)
6/9/2004 11:52:01 AM
excel.misc 78881 articles. 5 followers. Follow

1 Replies
566 Views

Similar Articles

[PageSpeed] 17

Odd that a space is giving you a problem.  This works for me whether the 
path has a space or not:

 Shell Range("A1") & "\123.bat"

-- 
Jim Rech
Excel MVP
"Pete Luffs" <Pete Luffs@discussions.microsoft.com> wrote in message 
news:C535AF64-4A09-4B4C-B8AD-0F6C9D35BE48@microsoft.com...
|I am trying to run a .bat file from a macro. The shell command works okay 
most of the time - but I cannot seem to make it work if there is a space in 
the path. (So, running C:\Apps\BFIle.bat works, but not C:\My 
Apps\BFile.bat)
|
| As the .bat file I want to run will change, I want to enter the path in a 
cell, and then run the macro with a button. This means simply enteing the 
path in double quotation marks in the Shell command will not work.
|
| BFile = Range("A2").Value
| i = Shell (BFile, 1)
|
| Any ideas? 


0
jrrech (1932)
6/9/2004 1:37:13 PM
Reply:

Similar Artilces:

Error when Running App with Scheduled Task
Error: Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application. In the Main module; I have the following lines of code (VS 2008) which shows a minimized form; executes the code and closes the form. Sub Main() Dim custForm As New CustomerForm custForm .ShowDialog() End Sub On 2/4/2010 6:52 PM, Ryan wrote: > Error: Showing a modal dialog box or form when the application is not runni...

Temporary save files and their accesibility
Hello, We recently altered an Excel workbook and have subsequently saved it, we have since found that ideally we would take step back in time and not make the changes we have. I have looked around the discussion topics only to be disappointed by some of the replies stating that what I’m asking is impossible. But here goes anyway: It is my understanding that when Excel saves it has a randomly named temporary file that it saves to, upon successful save the file is renamed to that of the file you are working on and the previously saved file is deleted. With that in mind surely there i...

bad file management
Ok, I may be missing something, or I may just be terrible at managing and upkeeping my files. Currently using Money Plus Home and Biz 2008, previously used 2006. I've never had a good standardized file management system or backup system/naming convention. Long story short, after changing computers, upgrading software, and moving to another country where I tried to start a new file with the local currency, I have all these various files and somehow am missing 3 months of 2007 data. I'm confused with all these files and wish there were some sort of a way I could merge th...

GP and CRM servers
I am currently running three different servers. One server (Windows server 2003) is running Dynamics GP 10. This server also acts as my terminal services license server. Access to this server is via remote desktop and server access is via “Users and groups” settings (not Active Directory). My second server (Windows server 2003) is running CRM 4.0 and active directory. My third server (Windows Server 2008) will eventually be a SharePoint (MOSS 2007) server. I am in an academic environment and my three servers are running on top of VMware 2.5 ESX on IBM Blade hardware. I have no ...

old file transfers
I have an old system running on 3.1, with business files on it I want to transferee these files to my other computer , it has xp system running. is there a patch I can download to my xp system which will let me open old excel documents If your xp computer has Excel installed, you should be able to open the old Excel file. If not, you can download an Excel Viewer from the Microsoft web site, that allows you to view and print files: http://www.microsoft.com/downloads/details.aspx?FamilyID=4EB83149-91DA-4110-8595-4A960D3E1C7C&displaylang=EN J B wrote: > I have an old system ru...

How to convert Excel file to PDF?
How do I convert an Excel workbook to PDF format? I can't find information about this in Excel Help. Thanks. You have to BUY a program that can create PDF files. Adobe Acrobat is the original. There are others available for less money. Search Google. On Mon, 4 Oct 2004 09:51:05 -0700, "YvonneP" <yvonnep@site-blauvelt.com.(donotspam)> wrote: >How do I convert an Excel workbook to PDF format? I can't find information >about this in Excel Help. Thanks. Using PDFwriter. Sarah "YvonneP" <yvonnep@site-blauvelt.com.(donotspam)> wrote in message ne...

Translate Word Perfect Files
Version: 2004 Operating System: Mac OS X 10.4 (Tiger) Processor: Power PC Is there any way to open a word perfect file, and then save it in Word format? Hello - Mac Word stopped including WordPerfect filters/converters several versions back. However, if you have access to a PC running Word you can probably open the file there & save it in .doc format - depending on which version of WP created the file. If the current versions of PC Word don't have the necessary equipment there are additional filters available from: http://gmayor.com/downloads.htm You may also be interested in a pr...

Excel doc saved as an HTML file
Hi, Sorry - this is a repost from microsoft.public.excel.programming. I posted there but maybe that was the wrong group for this question. Bottom line on top: I created an Excel file and saved it as HTML - and that file had a hidden worksheet. Upon reopening the file - I can no longer find the hidden worksheet. More detail: I am in the process of creating a dashboard for our group that is Excel based, but is saved as an HMTL file for ease of everyone viewing. In this early stage of development - I created just 3 tabs of reports and 1 tab of calculations. All the data is external, so...

copy spaced cells to different spacing
On one tab I have formulae in every 4th row that I want to copy onto another tab where I want the same formulae every 2nd row. The rows in between these formulae are not blank. How do I best do this? Derrick You can use code like the following: Sub AAA() Dim Source As Range Dim Dest As Range Dim LastCell As Long Dim WS As Worksheet Set WS = Worksheets("Sheet1") '<<< source of data Set Dest = Worksheets("Sheet2").Range("A1") '<<< destination of copy With WS LastCell = .Cells(.Rows.Count, "A").End(xlUp).Row Set Sour...

file date modified is diff
hi, I found after time saving switched, I found the same file have two diff date/time. It's one hour diff. I'm using window group. For example, on both pc , have same date/time clock, and file a.txt is 3/18/2010 3:45 when viewing from pc, but in winodw share view from another pc, it's 3/18/2010 2:45, one hour diff. Can someone pls help. Thanks. On Thu, 18 Mar 2010 15:59:53 -0500, <someone@js.com> wrote: >hi, I found after time saving switched, I found the same file have two diff >date/time. It's one hour diff. >I'm using window group. For ex...

Excel opens transparent when double-clicking a file
I recently had to reinstall Win2k on my PC. I didn't do a format, just reinstalled over the old directory. Of course I had to reinstall all app afterwards. I had some various Office problems and most have been resolved by removing and reinstalling Office (btw it's XP Pro). However I still have one weird problem. If I open a file by first starting Excel and using File | Open all is well but when I open Excel files from outside Excel, Excel opens and appears to function OK except that I cannot see any cells, the area where cells would appear is transparent, alllowing me to see whatever ...

Remove lines from text file prior to importing in Excel
I've scoured the usual sources, but haven't found any existing code that will accomplish what I need, so here's my situation. I've got a large text file from my company's mainframe. It's around 120,000 lines, with each record from a particular database taking up several lines (generally 8 to 16). Of those lines, only 4 of them are needed for the output file I need to produce. Since there is an import limit on Excel 2003, I'd like to remove the extraneous lines prior to the actual opening of the file in Excel. It should be pretty easy to isolate which l...

Double spaced header?
Hi, I would like to know what controls the spacing when receiving a email from Outlook?. Example, my print out looks like this when being mailed from a certain program (database). From: Sent: Subject: Sensitivity: Now what causes the double spacing? I need the room to keep data on one page.. I have noticed that other emails when printed ot are single spaced...Could there be code from within the program delling outlook how to format itself, or does outlook do the formating, I'm inclined to believe that outlook does not double space by default.. Any help is appreciated. Bill -- ----...

Recovering an overwritten file
How can I recover an old version of an excel file that I have saved over? Karen, Unless you have a backup...you can't. John "Karen" <anonymous@discussions.microsoft.com> wrote in message news:A196B312-6385-4C20-AFC4-9459A736846E@microsoft.com... > How can I recover an old version of an excel file that I have saved over? How do you know you actually saved over the old file. The only way you can be sure of that would be if you are using a floppy. Never read or write directly to a floppy from Excel. http://www.mvps.org/dmcritchie/excel/backup.htm If the file wa...

Launch file from button click
All, I am using the following code on a button click to launch a file from IE. Response.Write("<script type='text/javascript'>detailedresults=window.open('" + @fileName + "');</script>"); The string variable has the value : @FileName = "file://ourserver/testdir/excelfile.xls" This works occasionally, but sometimes makes IE hang and not respond. Any ideas/comments or better ways of simply opening a file via a button click TIA Ian Hi. Mira este link, ahi explica como hacer un sistema de descarga http://as...

Transforming an xml file w/ 2 xsl files
I am using the NITF DTD for my xml files and i need to use 2 xsl files to do the transform: one for the <body.head> and the second for the <body.content>. I've got this so far for transforming using 1 xsl file: Dim doc As New XmlDocument doc.LoadXml(xmlText) Dim xslDoc As New XslTransform xslDoc.Load(xslpath) Dim sw As New StringWriter xslDoc.Transform(doc, Nothing, sw, Nothing) PageContent.Text = sw.ToString sw.Close() Can i just pass the stringwriter to a new xml document and then do a transform like i did previously but using the second xsl file? Dim x2 As New XmlDocument...

Saving as PDF file
I am trying to convert an excel spreadsheet into a PDF file, what is the easiest way to accomplish this? Brian, Purchase Adobe Acrobat, install it, and press a button. Once you have Acrobat, the rest is very easy. Kevin "Brian" <Brian.Moddelmog@williams.com> wrote in message news:026101c37d4a$c9b4b120$a401280a@phx.gbl... > I am trying to convert an excel spreadsheet into a PDF > file, what is the easiest way to accomplish this? Brian, If you search about 5-20 messages down from yours, you will see the exact same question being asked. You can get more answers...

Spreadsheet files missing .xls extension
A client called saying that some Excel files had disappeared, but when I did a search for specific names they were found - without the .xls extension. They have no idea how they got renamed. Once they were renamed with the ..xls, they worked fine, but I'm baffled by how they could have lost their extensions. Any thoughts on this? Thanks, Cathy Your client may went gone into My Computer, Tools, Folder Options, View and checked "Hide extensions for known file types". -- Jim "Cathy C" <cchristian@aristotle.net> wrote in message news:34EF53EA-D790-401D-86B...

Problems importing in UTF8 file format w/ graphical characters
I have a text file that was generated in UTF8 that contains graphical characters (Japanese names). When I try to import the file into Excel UTF8 isn't in the 'file origin' drop down list so the characters don't import correctly and become corrupted. Is there a way to open these files in Excel? ...

Excel changes file name to numeric name when saving --HELP
When DFS is turned on, the name changes to a numeric name that includes date and timestamp. Enviorment Win2K SP4, replicating to a Win2k3 server. When Excel saves a file, it first saves it under a temporary name. If there are no errors during the save, it deletes the original file and renames the new version. Sounds like your network settings/permissions are not allowing Excel to delete the original file. On Fri, 4 Feb 2005 07:57:06 -0800, Greg Rinaldi <GregRinaldi@discussions.microsoft.com> wrote: >When DFS is turned on, the name changes to a numeric name that includes date >...

Problem with saving excel 2003 files on network
I have a recurring problem with Excel 2003, when a user is trying to save an existing file on the network after a few minor changes in the file. Excel will shut down and no changes will be saved in the original file. But a different file is saved in the same folder without the .xls extension This new file contains all changes and the file can be opened in Excel. We have 25 users and the problem arises about one time every day for one of the users. The problem did not exist in Excel 2000 (we upgraded to Excel 2003 a few month ago) Why does this problem arise? What can be done to ...

Where are the files with addresses to be checked
I'm running XP Home, Outlook 2000 all available updates. When addressing email, I type a name "Bryan" and Outlook auto-fills the rest of the name. I right click on the name, then Properties, and the email address is correct. I click Send and the email is sent out with a different, obsolete address. ?? I have checked Outlook by sorting my contacts by email, and have verified that the obsolete email address is not in my Contacts file. Where else should I look for this address? Can you tell me what Outlook checks when it autofills and then the message is sent? Hint: ...

Using one file on two computers
I currently have two networked computers in the house and would like to use both of them to access the same outlook file. Is there any magic to making this happen or do they both need to have seperate files. I could share the file on my main system and then have the laptop access it. However, I am concerned about being logged on on one computer and then trying to access the same files from the other other one. Ken ...

Converting files from 2007 to 2002 programs
-- I was a beta tester for MS Office 2007 and the test ended 02/01/2007. I spent six months as a tester and did a lot of work on my website with program. When the beta test program ended, I had to reinstall MS word 2002. Now the major problem is not being able to convert the files prepared from Word 2007 back to Word 2002. I go to open my saved files and this is what I come up with: "The file was created with a newer version of MS Word. Do you want to download a compatability pack so that you can work with this file". I go ahead and click the "OK" button. I com...

How to setup root path in CFileDialog
Hi All, Please let me know how to setup initial root path in Open/Save as common dialog boxes created through CFileDialog. TIA Vasis >Please let me know how to setup initial root path in Open/Save as >common dialog boxes created through CFileDialog. See the documentation on the lpstrInitialDir member of the OPENFILENAME structure (which is the m_ofn member of the CFileDialog). Dave David Lowndes wrote: >>Please let me know how to setup initial root path in Open/Save as >>common dialog boxes created through CFileDialog. > > > See the documentation on the ...