Determine a excel file exists or not by active x

I w a n t t o a d d t h e d i f f e r e n t d a t a a b o u t a s p e c i f i e d U U T t o d i f f e r n t w o r k s h e e t o f a s p e c i f i e d w o r k b o o k s . I f t h i s w o r k b o o k d o e s ' t e x i s t , t h e n c r e a t i t a n d s t o r e t h e d a t a . I f t h i s w o r k b o o k a l r e a d y e x i s t , t h e n o p e n i t a n d s t o r e t h e d a t e i n a n e w w o r k s h e e t . B u t h o w c a n t h e p r o g r a m k n o w w h e t h e r t h e e x c e l 9 7 f i l e e x i s t a u t o m a t i c a l l y ? T h e q u e s t i o n a b o v e i s b a s e d o n l a b
v i e w 5 . 1 a c t i v e x a n d e x c e l 9 7 .

Use Workbooks.Open(...) method which takes the XLS file path
to open. It returns a reference to the Workbook object if succeeded.
Otherwise this action raises a COM exception. Sorry but I don't
know how to handle COM exceptions in a general way. (I think
the Error Out control may report an error if failed.)
Makoto
"east" wrote in message
news:[email protected]..
> I w a n t t o a d d t h e d i f f e r e n t d a t a a b
> o u t a s p e c i f i e d U U T t o d i f f e r n t w
> o r k s h e e t o f a s p e c i f i e d w o r k b o o k s . I
> f t h i s w o r k b o o k d o e s ' t e x i s t , t h e n c
> r e a t i t a n d s t o r e t h e d a t a . I f t h i s
> w o r k
b o o k a l r e a d y e x i s t , t h e n o p e n i t
> a n d s t o r e t h e d a t e i n a n e w w o r k s h e
> e t . B u t h o w c a n t h e p r o g r a m k n o w w h e
> t h e r t h e e x c e l 9 7 f i l e e x i s t a u t o m a t
> i c a l l y ? T h e q u e s t i o n a b o v e i s b a s e d
> o n l a b v i e w 5 . 1 a c t i v e x a n d e x c e l 9 7

Similar Messages

  • How do I determine if a file exists or not on my PC?

    I thought this would be an easy one and maybe I am just making it harder than what it has to be. I simply want to search in a given directory to see if a file exists on not on my hard drive. Are there any ideas as to how to do this without causing an error if the file does not exist?

    Hi:
    In those situations what I've done till now is opening  the file
    and  close it inmediatly, if I find out and error while opening it
    I guess it doesn't exist. I know this is not the best way since there
    may be other reasons for the Open File Function to fail, but it has
    worked for me. Does somebody know a better way to do it?
    Regards
    Robst - CLD
    Using LabVIEW since version 7.0

  • I´m trying to open an excel file in numbers not being successful. The error msg is unexpectedly error using plugin SFCompatibility can you help me?

    I´m trying to open an excel file in numbers not being successful. The error msg is unexpectedly error using plugin SFCompatibility can you help me? Already changed the extension of the excel document to xlsx an now gives an unknown import error.

    In Excel have you tried saving directly to xls (not xlsx) and opening the xls in Numbers?
    If you have a complicated workbook in Excel that uses lots of Excel's advanced features, Numbers may not be able to handle the import.  It does pretty well on basic things, though.
    If you're just trying to get data into Numbers, then often copy-paste from Excel is easier than trying to open xls files.
    SG

  • File.exists() is not accurate on smb2 network share (use WatchService?)

    Hi,
    According to this document: SMB2 Client Redirector Caches Explained File.exists() is not accurate on a smb2 network share. I am not able to change any register settings, so I want to deal with it. According to the document there is an API to get the notifications from the file system. I assumed that the WatchService is the Java implementation of this API. Am I correct?
    I started with the WatchDir example from the jdk samples and stripped it a bit. I only need to know when a file is created and delete (I don't care about file modifications). For testing I have added new File.exists() when a new event has been triggered. I also start a separated Thread which test the file existence also. When I don't start this separated thread the file exists returns true immediately. When the extra thread is started it is not accurate any more. I need a more accurate file.exists check in the whole application and all running threads.
    The output for my test case is this:
    FileExistsThread: subdir\test.txt == false
    watch registered for dir: subdir\
    FileExistsThread: subdir\test.txt == false
    FileExistsThread: subdir\test.txt == false
    FileExistsThread: subdir\test.txt == false
    FileExistsThread: subdir\test.txt == false
    FileExistsThread: subdir\test.txt == false
    FileExistsThread: subdir\test.txt == false
    WatchDir event: ENTRY_CREATE: test.txt
    WatchDir: subdir\test.txt exists == false
    FileExistsThread: subdir\test.txt == false
    FileExistsThread: subdir\test.txt == false
    FileExistsThread: subdir\test.txt == false
    FileExistsThread: subdir\test.txt == false
    FileExistsThread: subdir\test.txt == false
    FileExistsThread: subdir\test.txt == false
    FileExistsThread: subdir\test.txt == false
    FileExistsThread: subdir\test.txt == false
    FileExistsThread: subdir\test.txt == false
    FileExistsThread: subdir\test.txt == true
    FileExistsThread: subdir\test.txt == true
    FileExistsThread: subdir\test.txt == true
    FileExistsThread: subdir\test.txt == true
    As you can see the file test.txt  is created on line 9. The FileExistsThread have seen it on line 20, (at least 10 x 300 ms later).
    For testing I have used 2 Windows 7 pc's (with smb2 enabled which is default). The working directory must be on the remote pc and the file test.txt must be created (or copied from another folder) on the remote pc (not using the network drive, but on the pc itself).
    Here is my test code:
    package nl.test.main;
    import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE;
    import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE;
    import static java.nio.file.StandardWatchEventKinds.OVERFLOW;
    import java.io.File;
    import java.io.IOException;
    import java.nio.file.ClosedWatchServiceException;
    import java.nio.file.FileSystems;
    import java.nio.file.Path;
    import java.nio.file.Paths;
    import java.nio.file.WatchEvent;
    import java.nio.file.WatchKey;
    import java.nio.file.WatchService;
    public class WatchDir
      private final WatchService _watcher;
      private final String _dir;
      public WatchDir( String dir ) throws IOException
        _dir = dir;
        _watcher = FileSystems.getDefault().newWatchService();
        Paths.get( dir ).register( _watcher, ENTRY_CREATE, ENTRY_DELETE );
        System.out.println( "watch registered for dir: " + dir );
      public void run()
        try
          while ( true )
            WatchKey key = _watcher.take();
            for ( WatchEvent<?> event : key.pollEvents() )
              WatchEvent.Kind<?> kind = event.kind();
              if ( kind == OVERFLOW )
                continue;
              @SuppressWarnings( "unchecked" )
              WatchEvent<Path> ev = (WatchEvent<Path>)event;
              Path fileName = ev.context();
              System.out.println( "WatchDir event: " + kind.name() + ": " + fileName );
              if ( kind == ENTRY_CREATE )
                String realPath = _dir + fileName;
                System.out.println( "WatchDir: " + realPath + " exists == " + new File( realPath ).exists() );
            key.reset();
        catch ( ClosedWatchServiceException x )
          return;
        catch ( InterruptedException ex )
          return;
      public static void main( String[] args )
        Thread t = new Thread( new Runnable()
          @Override
          public void run()
            try
              while ( true )
                String filename = "subdir\\test.txt";
                boolean fileExists = new File( filename ).exists();
                System.err.println( "FileExistsThread: " + filename + " == " + fileExists );
                Thread.sleep( 300 );
            catch ( InterruptedException e )
              e.printStackTrace();
              return;
        t.start();
        try
          new WatchDir( "subdir\\" ).run();
        catch ( IOException e )
          e.printStackTrace();
    Any idea's?
    Thanks,
    Olaf

    If you donot have access to note 45172.1 as specified by Laurent Schneider.
    Snippet from note
    a. Mapped Drive : To use a mapped drive, the user that the service starts as
    must have setup a drive to match UTL_FILE_DIR and be logged onto the server
    when UTL_FILE is in use.
    b. Universal Naming Convention : UNC is preferable to Mapped Drives because
    it does not require anyone to be logged on and UTL_FILE_DIR should be set to
    a name in the form :
    \\\<machine name>\<share name>\<path>
    or
    "\\<machine name>\<share name>\<path>"

  • How to test an image file existing or not

    Hi Everyone,
    I want to test whether an image file exists or not before setting the url of an image component in JSF to it. Following is my code:
    File testFile = new File(image_path + "/p1.jpg");
    if(testFile.exists()){
    info("file exists");
    }else{
    info("file not exists");
    this.myImage.setUrl(image_path+"/p1.jpg");
    Althoug the p1.jpg can be linked to myImage, the existence test always fails. That is, I got the message "file not exists" even though it is already displayed.
    What did I do wrong?
    Thanks in advance,
    Message was edited by:
    field

    File testFile = new File(image_path + "/p1.jpg");Is image_path an absolute path or relative path?

  • How to check whether file exist or not?

    hello,
    i wanted to know that how can i check whether a file exist or not independent of underlying Operating system?
    please help .
    Thank you.

    Use exists() on a File instance.

  • I have a old excel file that does not show hiding cell boxes on my Mac.

    I have a old excel file that has some hiding info. in some of the cell boxes.  I can not see them on my Mac computers.  When I click on the cells to see the hidden info. it does not show up.

    Are you using Mac OSX version of Excel or the Windows version of Excel?  Regardless being specific to Excel, it would be best to ask in the Microsoft Office forums.
    Microsoft Office for Mac forums
    http://www.officeformac.com/productforums/
    Microsoft Office for Windows forums
    http://answers.microsoft.com/en-us/office

  • Read a excel file...Not working in sap portal environment

    Hi,
    I have a requirement to read an excel file from presentation server. I have used funtion module TEXT_CONVERT_XLS_TO_SAP. This is working in production system.
    But this read is failing in PORTAL environment as i am getting an error " excel file cannot be processed".
    Please let me know if anyone knows how to solve this issue...
    Regards,
    San

    Dear Shankar,
    I can see the form in R3 using asr_process_execute application but not in portal.
    one of most strangest error I have seen.

  • Excel files deleted when not found

    I am using the Report Generation toolkit for Microsoft Office. I have a vi that opens a template, renmaes it, saves it, and writes to an Excel file. The file is then saved again before the vi exits.
    The problem is if the Excel file is accidently closed, then the vi closes and tries to save the excel file, it deletes the file that was saved. This seems to happen in the NI_Excel.lvclassave Report to File.vi, and comes up with error -2147417848 The first three case structures are false, which leads to the close and delete file subvis. I thought I could get remove the delete file vi, but I can not rename the subvi (...save report to file) to do this. This problem is causing me to lose product data.
    How can I either make a copy of the sub vi, or prevent the subvi from deleteing the file if the file is not open?
    metzler CLAD

    Hi metzler,
    According to this KnowledgeBase Article: Close Microsoft Excel While Running Report Generation Toolkit it is recommended programming practice to catch and handle the resulting error if the user attempts to quit Microsoft Excel mid-execution.  In no way will NI recommend editing its shipping VIs.
    I hope this helps!
    - Greg J

  • How to check whether a file exists or not

    i am in an image uploading utility. i hav succesfully uploaded the image to the server directory (say /uploads). but when displaying the uploaded image, i wanna show the picture only if the image exits (bcoz for some records there is no image). so i hav used this code
    if(new File("uploads/1.jpg").exists())
         out.print("image exists");
    but its not working for me. i got it working fine when i give the full path "D:/Tomcat/webapps/diary/admin/uploads/1.jpg". but i think giving this absolute path is not an efficient method bcoz its a web application, bcoz i may not be able get the absolute path always. so how can i do this by specifieing the relative path
    help me ASAP if u can
    aleens

    Haii ameen
    This is one way to rectify your problem..
    if(new File("uploads/1.jpg").exists())
    out.print("image exists");
    instead of this u can write like
    <%
    ServletConfig cf=getServletConfig();
    ServletContext c=cf.getServletContext();
    if(new File(c.getRealPath("uploads")+"/test.txt").exists())
    out.print("image exists");
    %>If u are not clear of what it is done let me know..i will xplain to you furthur...
    Happy New Year
    Shanu

  • URGENT!!! how to check whether file exist or not on client side?

    hello,
    i am building appilication using JSP and javabeans.
    Problem is my application is like on server files are there for say colors and their corresponding car image in that color.so when i move my mouse over that particular color ,its corresponding car image is displayed.
    now say someone has deleted that corresponding car image file but image of color is there...........
    so i have to handle such excpetion.
    like if corresponding car image for that color is not there then that color image should also not be displayed.
    i dont want to do this checking on server side.
    pls help me!!!!!!

    You don't have access to the client files. It is a security violation in a normal internet environment. Imagine what people could do to your computer if they could see everything on it.

  • Checking to see if files exist not working as expected.

    Hey, so I've set up a script that determines the artist playing on iTunes and sets the background image to a preselected picture of them. I want to expand this to allow different pictures of the artists, and after a few attempts, decided to use a time based system. However, some artists have 2 images (named Artist1.jpg and Artist2.jpg), whilst others only have one (Artist.jpg). I can get the scripting right for if all artists have 2 images, yet am having problems with the system determining if certain files exist.
    who is the artist playing, and myNum is either 1 or 2, and changes based on the time, both set earlier in the script and verified to work.
    set MultiWall to ("/Users/ethan/Pictures/Music Wallpaper/" & who & myNum & ".jpg")
    set SingleWall to ("/Users/ethan/Pictures/Music Wallpaper/" & who & ".jpg")
    tell application "System Events"
                       if not (exists MultiWall) then
                                                           tell application "Finder"
                                                                          set desktop picture to file SingleWall
                                                           end tell
                       else
                                                           tell application "Finder"
                                                                          set desktop picture to file MultiWall
                                  end tell
                                            end if
    end tell
    I've tried many variations of this, from less variables to more, restructuring it and whatnot and it just isn't working for me. Thanks all.

    If you are still having difficulties you may like to try this method:
    set myPath to "/Users/neville/Desktop/test" & ".png"
    if (do shell script "/bin/test -e '" & myPath & "'; echo $?") is "0" then
      tell application "Safari" to open myPath
    end if
    It should work if you copy and paste it.
    Please note the combined single and double quotes. Don't put a space between them. You may not need the single quotes if you have control over the path. Most people would opt for 'quoted form of' but I prefer concise code.

  • How to Append an existing Excel file?

    I am using the jexcel api to write to a new excel file. Each time i run my program, it creates a new Excel File by the name i give it. my code to create the excelFile is as below:-
    File excelFile=new File(workDir+"\\"+fileName+".xls");
    WritableWorkbook workbook = Workbook.createWorkbook(excelFile);
    After this code i write some data to a worksheet in the above mentioned excel file. But my requirement is that I want to create the excel if it does not exist, and if it exists, then the data should be appended to the worksheet in the existing excel file. At present it creates a new excel file and does not append it.
    How can it be done? does anyone have any suggestions as to how can i tackle this problem? please suggest something.
    Ankit

    There is no ready-to-run example, as you are searching for, available.
    This has several reasons:
    - It depends on the version of Excel. Examples for Excel 2007 might not work with Excel 2010 for instance.
    - No one just wants to open Excel without doing anything with it.
    The second point is something, i want to ask you:
    Why do you want to open an existing Excel file at all? What is it, what you want to do after opening it?
    If you have LV/C/C#/VB examples doing what you are looking for, why do you want to have it in TestStand directly, so NOT using existing code (saving time and effort) and basically re-inventing the wheel?
    ActiveX is an interface for remote controlling and embedding applications with/in other applications on Windows systems. It is a PROGRAMMING interface.
    So naturally, examples and tutorials exist for programming languages. Those examples are easily converted to TestStand sequences with a basic knowledge of the programming language and TestStand. Providing links for such tutorials/examples is a valid way to give support to fellow developers because we expect the fellow to have that basic knowledge. 
    If that knowledge is not present, i highly recommend to fill that gap.
    just my 2 cents,
    Norbert
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • How to export diadem channels to an existing excel file with a certain configuration

    Hello,
    I would like to export some channels from the Data Portal of Diadem  to an existing excel file. The excel file consists of many spreadsheets and each channel  should match one spreadsheet.
    I´ve tried to use EXCELExport() function but it doesn´t work.(this function is designed for something else, it generates a new excel file). I´ve tried to access to each spreadsheet and copy the information throughout a for statement but this solution needs a lot of time. If somebody has any idea, please help.   
    Solved!
    Go to Solution.

    Hi Ovidius,
    You have two options that I can think of.  You can export the data from the Data Portal to a temporary file, probably a CSV file, then load the data from file into the Excel template, OR you could stick with the Excel ActiveX approach but change to assigning a range of cells instead of individual cell values one at a time.
    There is an Excel File Export option in DIAdem, but it always creates a new Excel file, it can not be used to export to an existing Excel file.
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments

  • Java.io.File exists() problem

    I have a web application deployed on a Windows 2000 server and am running Tomcat 4. I want to check for the existence of an image file before displaying it and am trying to use the java.io.File.exists() method. I am using the following code:
    String strPicUrl = "/images/thefile.jpg"; //Actual value comes from database
    File theFile = new File(application.getRealPath(strPicUrl));
    out.print("File Exists: " + theFile.exists() + "<br>");the actual file name in this example is "/images/theFile.jpg", and theFile.exists() always returns true if the file is there, but differs in case. If I try to display the image it doesnt show up under Tomcat because aliasing is turned off by default. I need to find a way to determine if a file exists based on actual case matching. This way if I get a "true" value, the file should be accessible and/or viewable via the JSP engine.
    Any ideas how to perform a case sensitive "exists()" regardless of the underlying OS file system?

    This looks awesome, but when I tried to implement it without creating a class, I get a method error. Here is the code below:
    String theDir = "C:\\Dir\\Subdir\\";
    FileFilter theFilter = new FileFilter() {
         private String _theFile = null;
         public boolean accept(File file)
              if (file.isDirectory()) return false;
              String fileName = file.getName();
              if (fileName.endsWith(_theFile)) return true;
              return false;
         public void setTheFile(String theFileParam)  
              _theFile = theFileParam;  
    theFilter.setTheFile("theFile.jpg");When I run this I get the following error:
    [javac] ...blah error stuff...
    [javac] cannot resolve symbol
    [javac] symbol : method setTheFile (java.lang.String)
    [javac] location: interface java.io.FileFilter
    [javac] theFilter.setTheFile("theFile.jpg");
    Since I am invoking the FileFilter object directly and not instantiating it in a class, is that causing the error or am I declaring "setTheFile()" wrong?

Maybe you are looking for

  • How can i get my info back if it wasn;t stored but on phone not in icloud or itunes?

    My son took phone in for repair and the idiot that was working did not back up my sons phone for him and my son hadn't backed it up for a while because I have laptop in different state and didn't have Icloud on.  Is there anything we can do to get so

  • Different units in total sum row

    Hello Bex Experts, I have orders with different Units in a report. currently the total sum row show * for Mix How can I get the total sum for ST and KG like Total Sum 366 KG Total Sum 342 ST BR Matthias

  • App World applicatio​n in foreign Currency

    I just down loaded the latest App World download and all the Currency is in a foreign Currency, how do I change it back to U.S. Currency

  • Help with Scripting forms when additional characters added

    Hi, I am new to scripting in adobe professional, I thank anyone in advance for any advice or help they can give me. I am trying to use the calcuations within the forms that I am putting fields onto.  In the process I discovered that the program the f

  • Issues with VPN on 10.3 Server

    I have no problems using the VPN with 10.4 Server. I manage several of these, and the VPN works fine. However, with 10.3 Server it doesn't seem to work. I have two 10.3.9 servers at different offices, and with each I can connect to the VPN, I get an