Problems with spaces in directory or file names and Word.exe

Hi
I'm trying to open a file with Word from my java aplication, and I have a problem with some file/directory names.
I have this
String cmd = "c:\\Program Files\\Microsoft Office\\Office10\\WINWORD.EXE" + " " + path;
try {
Runtime.getRuntime().exec(cmd);
} catch (Exception errorea){ }
Here is what happens:
if path is something like this: "c:\people\info.doc" , there's no problem, Word opens the document, but if path contains blank spaces somewhere, it doesn't work. For example:
path = "c:\Documents and Settings\info.doc"
path = "c:\Hi everybody\info.doc"
path = "c:\tests\test results.doc"
with the above examples it doesn't work :( Word tries to open "c:\Documents", "c:\Hi" or "c:\tests\test".
Can anyone help? thanx a lot ! : )

No, the exec method runs the Word.weird, it shouldn't, and it wouldn't on my system going by the test I just made, but I'm running linux & not windows, maybe the command line parsing is different for some reason.
The problem is that
Word starts and then Word says that it can't open the
file because the name or the path to the file is not
valid.You still should use the overload that takes a String array.

Similar Messages

  • Problems with spaces in file or directory names and Word.exe

    Hi
    I'm trying to open a file with Word from my java aplication, and I have a problem with some file/directory names.
    I have this
    String cmd = "c:\\Program Files\\Microsoft Office\\Office10\\WINWORD.EXE" + " " + path;
    try {
    Runtime.getRuntime().exec(cmd);
    } catch (Exception errorea){ }
    Here is what happens:
    if path is something like this: "c:\people\info.doc" , there's no problem, Word opens the document, but if path contains blank spaces somewhere, it doesn't work. For example:
    path = "c:\Documents and Settings\info.doc"
    path = "c:\Hi everybody\info.doc"
    path = "c:\tests\test results.doc"
    with the above examples it doesn't work :( Word tries to open "c:\Documents", "c:\Hi" or "c:\tests\test".
    Can anyone help? thanx a lot ! : )

    Hint: use the variant Runtime.exec(String[] args).
    Create a command array, with each token in a separate argument. The entire filename with spaces goes into one argument.

  • Download problem with JSF: Cannot open PDF-file after opening WORD-file

    Hello,
    I have a JSP (created with Java Studio Creator) which displays a table with links to different files. Some links open PDF-documents, other for instance DOC-files (msword). I download the file as follows:
    public String downloadFile(String fileName) {
    try {
    int dotIndex = fileName.lastIndexOf('.');
    String fileExtension = "";
    String contentType = "";
    if(dotIndex > 0) {
    fileExtension = fileName.substring(dotIndex+1, fileName.length());
    contentType=CONTENT_TYPES.get(fileExtension.toUpperCase()).toString();
    if(!fileExtension.equals("") && !contentType.equals("")) {
    // method that reads file to the byte array
    byte[] fileContent = getContentOfFile(new File(fileName));
    FacesContext faces = FacesContext.getCurrentInstance();
    HttpServletResponse response = (HttpServletResponse) faces.getExternalContext().getResponse();
    response.setContentType(contentType);
    response.setContentLength(fileContent.length);
    response.setHeader("Content-disposition", "inline; filename=\""+fileName+"\"");
    try {
    ServletOutputStream out;
    out = response.getOutputStream();
    out.write(fileContent);
    } catch (IOException e) {
    e.printStackTrace();
    faces.responseComplete();
    catch(Exception ex) {
    return ("!!!ERROR: downloadFile(fileName) - Could not completely download file "+ fileName + ex.getMessage());
    return "";
    contentType is application/pdf if it`s a PDF-file or application/msword if it`s a word-file.
    fileName contains the full file path.
    link-properties:
    <ui:hyperlink action="#{showOriginalPDF.hyperlinkShowPDF_action}" binding="#{showOriginalPDF.hyperlinkShowPDF}"
    id="hyperlinkShowPDF" immediate="true" onClick="testSubmit()" target="_blank" text="#{currentRow.value['display']}"/>
    and the code of the JS-function testSubmit() (without this function I couldn�t get the right row selection in the hyperlink-table):
    function testSubmit() {
    document.getElementById('form1').submit();
    return false;
    All pdf-links are working fine and the correct document is displayed in a new browser window. but if I open a WORD-document and after that I click on another link to a pdf-file, the WORD-file is loaded again in the new window. Only if I close the window which contains the WORD-document, I can download the correct pdf after that.
    Is something wrong with the response header (I tried "attachment" instead of "inline" too but without effect)?
    Can anybody help?

    More than you asked for but good stuff. Permissions is buried in there somewhere.
    Reading
    [Resolve startup issues and perform disk maintenance with Disk Utility and fsck|http://docs.info.apple.com/article.html?artnum=106214]
    [Using Disk Utility in Mac OS X 10.4.3 or later|http://docs.info.apple.com/article.html?artnum=302672]
    [Disk Utility's Repair Disk Permissions 10.0-10.6|http://docs.info.apple.com/article.html?artnum=25751]
    "Try Disk Utility" (modified from [http://support.apple.com/kb/TS1417])
    1. Insert the Mac OS X Install disc that came with your computer (Edit: Do not use this disc if it is not the same general version as what you have currently on your computer, e.g. use a Tiger disc for a Tiger drive, not a Panther disc), then restart the computer while holding the C key.
    2. When your computer finishes starting up from the disc, choose Disk Utility from the Installer menu. (In Mac OS X 10.4 or later, you must select your language first.)
    Important: Do not click Continue in the first screen of the Installer. If you do, you must restart from the disc again to access Disk Utility.
    3. Click the First Aid tab.
    4. Click the disclosure triangle to the left of the hard drive icon to display the names of your hard disk volumes and partitions.
    5. Select your Mac OS X volume.
    6. Click Repair. Disk Utility checks and repairs the disk.
    Then boot in Safe Mode, (holding Shift key down at bootup; takes longer to boot this way so be patient), run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, reboot when it completes.
    [Mac OS X: Starting up in Safe Mode|http://docs.info.apple.com/article.html?artnum=107393]
    [What is Safe Boot, Safe Mode? (Mac OS X)|http://support.apple.com/kb/HT1564]
    [Safe Boot takes longer than normal startup|http://docs.info.apple.com/article.html?artnum=107394]
    [Mac OS X 10.4, 10.5- Computer shuts down during Safe Boot|http://support.apple.com/kb/TA24054]

  • Problem with getting the file name and type from OAMessageFileUploadBean

    Hi Tapash,
    I am trying the code below to get the file name and mime type from OAMessageFileUploadBean,
    DataObject fileUploadData = (DataObject)pageContext.getNamedDataObject("Documents");
    String uFileName = (String)fileUploadData.selectValue(null, "UPLOAD_FILE_NAME");
    String contentType = fileUploadData.selectValue(null, "UPLOAD_FILE_MIME_TYPE");
    But this piece of code gives errors saying that selectValue selectValue(null, java.lang.String) not found in class oracle.svc.DataObject
    Any ideas? why this code is giving error?
    Can i handle the event of browse button for OAMessageFileUploadBean?
    Regards,
    Nagesh Manda.

    Try using class oracle.cabo.ui.data.DataObject
    --Shiv                                                                                                                                                                                                       

  • Problem with Spaces that started with Snow Leopard

    I've noticed two problems with Spaces that have arrived since switching to Snow Leopard... First, if I am in say Space 1 where I use Safari and I then want to move over to an open application, say like Excel, that I have running in Space 4, there are a number of ways to get there but one way I used to use all the time was to move down to the Dock and simply single click on the open Excel application and that would immediately switch me over to Space 4 and whatever Excel documents were already open there... Now, since switching to SL, a single click of whatever application in the Dock makes that application active in the Finder (you see its name appear in the upper left of the menu bar) but otherwise nothing happens... You then have to click a second time and then you switch over to Space 4... It's not really a double click because that implies to clicks closely spaced in time... For this, you can click once, leave the room, come back, click a second time and you will now switch to the alternate space where the open application is running... That is clearly different than it was under Leopard and I would suggest that it is a bug because there is no value in the outcome of that first click... It highlights the switched application but doesn't actually switch to it until you click a second time...
    Second, and this one is worse, if you say launch Excel (which you want to open in Space 4) while you are in Space 1, Excel will open and switch over to Space 4... So far so good... But now, with Excel open over in Space 4, if you are now back and working in Space 1 and while there you use the Finder to go to some other, currently unopened, Excel file and request that it open, it should switch over to Space 4 and open that file but instead it opens it wherever you are, in the case mentioned here, in Space 1... So now you have Excel files opened both in Spaces 1 and 4... Clearly a bug... Spaces had some similar issues in a few early versions of Leopard but they eventually got it working... Now it appears Spaces has regressed somewhat in SL... I love spaces and use it all the time... Hope it gets fixed soon... thanks... bob...

    Hi... I have since learned that the first paragraph of my original post where I say,
    "I've noticed two problems with Spaces that have arrived since switching to Snow Leopard... First, if I am in say Space 1 where I use Safari and I then want to move over to an open application, say like Excel, that I have running in Space 4, there are a number of ways to get there but one way I used to use all the time was to move down to the Dock and simply single click on the open Excel application and that would immediately switch me over to Space 4 and whatever Excel documents were already open there... Now, since switching to SL, a single click of whatever application in the Dock makes that application active in the Finder (you see its name appear in the upper left of the menu bar) but otherwise nothing happens... You then have to click a second time and then you switch over to Space 4... It's not really a double click because that implies to clicks closely spaced in time... For this, you can click once, leave the room, come back, click a second time and you will now switch to the alternate space where the open application is running... That is clearly different than it was under Leopard and I would suggest that it is a bug because there is no value in the outcome of that first click... It highlights the switched application but doesn't actually switch to it until you click a second time... "
    ...that turned out to be my mistake... In another post someone pointed out that in Spaces preferences you must have checked ON the preference that says,
    "When switching to an application, switch to a space with open windows for the application"...
    I had been playing with a number of things trying to figure out what was going on and somewhere in the mix had switched that off... (It is on on all my other computers and I'm sure it originally was on this one too)... When I switched it back on the above described problem went away... So that was my fault...
    But the second part,
    "Second, and this one is worse, if you say launch Excel (which you want to open in Space 4) while you are in Space 1, Excel will open and switch over to Space 4... So far so good... But now, with Excel open over in Space 4, if you are now back and working in Space 1 and while there you use the Finder to go to some other, currently unopened, Excel file and request that it open, it should switch over to Space 4 and open that file but instead it opens it wherever you are, in the case mentioned here, in Space 1... So now you have Excel files opened both in Spaces 1 and 4... Clearly a bug... "
    ...is a real problem... I fired up my G4 (power pc) that runs Leopard, 10.5.8, to see whether it behaves the above way or not and it does NOT... It works as one would expect.. So at least later in Leopard, the above mentioned problem was not present but it is in this first incarnation of Snow Leopard...
    To me, the utility of Spaces is all about keeping a single desktop from being cluttered with many open applications/files and to now have an application that opens in whatever space you happen to be in after it is first opened in its "correct" space sort of defeats the idea behind Spaces... I am currently trying to train myself to first hit <command><4> (my Excel space) before opening a second or subsequent Excel document to prevent it from opening somewhere where I don't want it to be...
    Again, I hope Apple sees and fixes this... I did submit an "Apple feedback" item for this issue... thanks... bob..

  • Problem using af:inputfile when only file name is given without path.URGENT

    Hai Friends,
    I am using input file type and <h:commandLink to upload a file. But when I type only the file name without the path like(hello.jpg) and try to submit then a javascript error occured "Access is denied". But my requirement is when i type without the path, that is only the file name i need to do some validations, like appending a global path with this file name and upload the file... the following is the code am having...
    <af:form id="address" usesUpload="true" >
    <af:inputFile id="id" value="#{BKb.batchFile}"/>
    <h:commandLink action="#{.uploadFile}">
    <h:outputText value="Upload" styleClass="buttonNoDecoration"/>
    </h:commandLink>
    <h:commandLink action="#{BKb.clearFile}">
    </h:commandLink>
    </af:form>
    can u help me in this issue...
    Thanks in advance,
    Ciya

    I figured out the problem, and it was caused by JHeadstart. I placed a default display value in JHeadstart for the download link. This caused a default values bean to be created by jheadstart and that bean was what was causing my problem. The download link had a display value, but not a valid path. I removed the default value, re-generated the screen and it is totally fixed. I have pretty much decided that it is never a good idea to use a default value in Jheadstart.
    Thanks for your help,
    Michelle

  • Dynamic File Name and Directory File Sender Adapter

    Hello gurus,
    I have a question: Is there any way to make the File Name, and Directory Dynamic of a File Sender Communication Channel ?
    For example, taking it as a parameter from a Web Service Request.. (I mean, the only way with this would be a ccBPM). I don't exactly know if there is a way, I just thought about this.
    Please tell me if someone could make Dynamic these 2 parameters while picking a file.
    Regards,
      Juan

    oops,thought i was replying to the PgP question:)
    I think you should be able to achieve this via adapter module but i m not really sure how exactly it will be done .
    Thanks
    Aamir
    Edited by: Aamir Suhail on Jul 28, 2009 1:42 PM

  • Read Document in FileUtilities  cannot search a file with french character in the file name

    Hi,
    I am trying to search a file with french character in the file name like 'captures écran.doc' in my unix server directory, and Write the file somewhere, say in a list of documents or, write on file system to another directory.
    I am using to Read Document in FileUtilities of Foundation, but it cannot read the file due to french character in its name. Although it can find any other file name without these french characters.
    Tried renaming but that also cannot find the file with french character name.
    Please provide any idea to solve it using LC operation.
    Regards,
    Rohan Raj.

    Hi Thomas,
    Thanks for the post, but I have already found a solution to it a month ago. Sorry for not posting the solution.
    You just have to set the '-Djava.property.file.encoding=ISO8859-1' into JVM argument of your server startup, and bounce the server back to pick the new JVM arg set. And now the service Read Document in FileUtilities of Foundation will read all french characters.
    ISO8859-1refers to "Latin alphabet no. 1," consisting of 191 characters from the Latin script. This character-encoding scheme is used throughout The Americas,Western Europe, Oceania, and much of Africa. It is also commonly used in most standard romanizations of East-Asian languages.
    regards,
    Rohan Raj.

  • Iphone contacts "not available" to car phonebook after messing around with Outlook.pst file names and backups. Iphone4 connects to car though and other phones connect properly.

    iphone contacts "not available" to car phonebook after messing around with Outlook.pst files, names and backups, on my ms XP 2003 laptop. I substituted a much smaller new Personal Folder -Contacts File, with a smaller list of phone numbers (4 only as a test) which successfully synced to the iPhone 4. The iPhone connects to the Skoda Octavia HandsFreeSystem OK (Bluetooth works fine), but now iPhone wont load the new Contacts as it did originally. However a family Nokia (never messed with) can connect properly. So must be the iPhone or more likely an Outlook.pst \ Contacts problem. Ideas?

    After fiddling a little more, the following fixed my corrupted outlook.pst file:
    1) I made a backup
    2) In outlook under file, I exported the calendar to excel
    3) In outlook under file, I imported the calendar back to outlook
    And voila, it worked.

  • DW CS5.5 in OSX Lion - anyone seeing problems with Spaces?

    DW seems to have problems with Spaces in OSX Lion.Switching into DW from other spaces is not 'clean'. When DW comes up, sometimes the Code/Design is blank white, and windows within the workspace don't show their headers. Clicking on Code/Design redraws that window, but the only thing that seems to recover the window headings is switching to and then back from another app in the same Space.
    Seems like screen redrawing triggered by switching apps within the same Space is a little different than that triggered by switching apps across Spaces.
    Anyone else seeing this?

    I did report it as a bug, using the link kindly provided by you and Shocker.
    The two Macs I've tried this on now are a Mac Pro and an iMac, so there's no Automatic Graphics Switching option to enable/disable.
    I was only able to check this out on the iMac late last night.
    Hardware synopsis:
    Mac Pro Early 2009
    Processor  2 x 2.93 GHz Quad-Core Intel Xeon
    Memory  16 GB 1066 MHz DDR3 ECC
    Graphics  NVIDIA GeForce GT 120 512 MB
    Software  Mac OS X Lion 10.7 (11A511)
    The iMac isn't available to me at the moment, I'll have to fill in missing details later (can't remember the exact graphics card info):
    DW is CS5, not CS5.5, was also installed well ahead of the Lion upgrade
    Computer is iMac instead of Mac Pro, about 1.5 years old
    Quad-Core i7
    4GB memory
    Mac OS X Lion 10.7
    I used the same procedure upgrading to Lion on the iMac...
    Ran Cocktail 'Pilot' to clean up the system prior to install (runs Daily, Weekly, Monthly maintenance scripts, clears System, User, and Internet caches, repairs disk permissions on "Macintosh HD", clears log files)
    OS10.7 was purchased through the Mac App Store and installed.
    JRE installed.
    DW on the iMac exhibited the same problem as on the Mac Pro.
    To reproduce:
    Start DW, open a file for editing
    Start any other app in the same Space
    Open a new Space, open any other app there.
    Test switching between DW and other apps in the same Space compared with switching between DW and other apps in different Spaces.
    Consistently, when I switch between DW and other apps in the same Space, DW's windows/panels redraw properly,
    and when I switch between DW and other apps in different Spaces, DW's windows/panels don't redraw properly.

  • Save As with suggested file name and folder

    I would like the user to be able to press a save button on the pdf and the "Save As dialogue box" pops up pre-populated with a file name and location choosen. The user can then choose to name the file something otherwise or select a new location. I would just like to save them the steps of copying the field data and finding the correct folder (deeply buried on server) however to place the finished document in.
    This doesn't seem to require a trusted function, but how do I suggest the file name based on a field name in the document. And how do I suggest the folder the document should be saved into?
    Thanks in adavance.

    Hi,
    you need a folder level script to use the browseForDoc method.
    http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_api_reference.pdf#page=10 4

  • A problem with copying text from english pdf to a word file

    i have a problem with copying text from english pdf to a word file. the english text of pdf turns to be unknown signs when i copy them to word file .
    i illustrated what i mean in the picture i attached . note that i have adobe acrobat reader 9 . so please help cause i need to copy text to translate it .

    Is this an e-book? Does it allow for copying? It is possible that the pdf file is a scan of a book?

  • When importing photos with iBooks Gallery widget, is anyone aware of a technique for simultaneously importing the photo's description (or jpeg file name) and writing it into the iBook Author caption field for the imported photo?

    When importing photos with the iBooks Author Gallery widget, is anyone aware of a technique for simultaneously importing the photo's description (or jpeg file name) and writing it into the iBook Author caption field for the corresponding imported photo? I have 4,800 stills to import and can't imagine it's necessary to copy and paste the description for each.

    As always, feel free to use the 'Provide iBooks Author Feedback' menu item for features you'd like added in the future, etc.
    http://www.apple.com/feedback/ibooks-author.html
    As for AS, I'm not sure anyone has sniffed iBA's dictionary yet...google is you friend for hot prospects, I'm sure

  • Serving up files with Russian chars in the file name

    Anyone know how to get CF 8 to serve up CFM files with
    Russian characters in the file name? I can get IIS to server up
    .html files but .cfm files turn in to ?????????.cfm files.
    For example, this:
    новостииобновления.cfm
    becomes this ??????????????.cfm and throws a CF error (File Not
    Found) when clicking on the link. The strange thing is I can see
    the Russian characters in the status bar when I mouse over the link
    but CF can't handle it. And IIS will serve up the file and replace
    all the chars with their URL entity equivalent.
    Any suggestions on how to fix?

    Open the Script Editor or AppleScript Editor in one of the subfolders of Applications and run the following:
    tell application "Finder" to quit
    if (do shell script "defaults read com.apple.finder AppleShowAllFiles") is "1" then
    do shell script "defaults write com.apple.finder AppleShowAllFiles 0"
    else
    do shell script "defaults write com.apple.finder AppleShowAllFiles 1"
    end if
    delay 2
    tell application "Finder" to run
    If you change your mind later, run the script again.
    (93787)

  • File Name and Target Directory name issue in FTP CC

    Hi All ,
    I am using following code to assing file name and directory name in UDF. I don;t want these parameters to be part of my target structure. Since i have created these files names in UDF, what are the values do i need to mention in FTP CC's "File access Parameter" which are mandatory fiels in CC ?
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create(u201Chttp://sap.com/xi/XI/System/Fileu201D,u201CFileNameu201D);
    String myFileName =biz +".dat";
    conf.put(key, myFileName);
    //Similar code for direcotry
    Thanks for your support.
    MK

    Hi,
    in ID in receiver file comm channel, just tick the option of Adapter Specific messge attributes and in it tick FileName and DirectoryName.............
    the filename and directory you give in comm channel will be treated as dummy and the values will be taken from your UDF.......
    Regards,
    Rajeev Gupta

Maybe you are looking for

  • Not able to run standard iProcurement Shopping cart page through jDevloper10g in R12.1.3

    Dear All, I am trying to run standard iProcurement Shopping cart page (Negotiation Tab) through jDevloper10g in R12.1.3 instance but on click of "View Cart and Checkout" button it gives an exception as "ArrayIndexOutOfBoundsException". I had copied t

  • How to Find the node or leaf node selected in Tree UI element:

    Hi All, I have a tree structure with three level design. We have a button, which will perform some operation on the specific node or leaf node on every level. When we select any node or leaf node, we have action Onction getting called.  But what we w

  • Photo quality dropped

    At the same time I stopped getting any thumbnails in Iphoto, when I open a picture in Photoshop, the image quality is now very poor. I get a 3X5 photo at 72 dpi, when it used to be 22X17 at 72 dpi. File size is now point 1 MB, when it used to 3.5 MB.

  • Typing Information During Presentation (Interactive Presentation)

    I'm currently using Keynote '09 and had a question about a setting which I'm not sure exists or not. I am doing a presentation in a few days and part of it asks for input on ideas from the audience. Instead of writing down what they say on a nearby w

  • How to change value of array element using property node

    hello all : ) im using an array of combo-box. the size of array is not fixed. i want to use the strings[ ] property of combo-box to enter selection texts but since i have placed it inside the array im unable to use this property. i used 'arrayelem' r