Write into worksheets and close excel

can someone tells me why this doesnt work?
i tried to
open excel, open worksheet, write to new worksheet #2, autofit to one page for work sheet #2,
write to new worksheet #3, autofit sheet #3. 
all those are working...
but when i tried closing the excel and saving it is when i have alot of errors. 
can someone help me?
thanks
Attachments:
Untitled 1.vi ‏18 KB
Untitled Project 1.lvproj ‏7 KB

I'm not sure which version of LabVIEW you are using, nor what some of the VIs are in your code.  However, if you have a recent version of LabVIEW (say 2012 or later) and have access to the Report Generation Toolkit, you will have a much easier time working with Excel.
In January of this year, I posted an Example to replace the Excel example that ships with LabVIEW.  However, I'm not very good at finding my own posts on this forum, so I can't easily point you to it.  However, if you do use the Report Generation Toolkit and do not use ActiveX calls, you will find that the functions to open and close Excel Reports tend to work without significant problems (there is a glitch, that I've reported, whereby if you "manually" close the Excel Workbook and then try to close it with the Report Generation's "Save Workbook", it will actually delete the manually-saved Workbook for you)(there is a "work-around" until NI fixes this ...).
Bob Schor

Similar Messages

  • Automatically open, save and close excel?

    I need import data from Excel to SQL.
    Now, I use tSQL to directly read the excel files and transform to the SQL table.
    As the user Excel is not a good format for SQL to read, I need use formula to transform the excel to be a SQL readable format.
    Now, I add a sheet to copy the data from the sheet which user input the data and then ask the user to copy the excel to a specific location for import.
    However, this will make the data in the excel double and result a large excel file.
    I am thinking if it is possible to create a excel to use formula to copy the data from another excel.
    Then, I need find some method to open that excel, let the content refresh from the source excel, save and close it.
    Then I can directly use this excel for data import.
    Is there any simple way to do so? I don't know marco much...
    Ivan

    No formula could do this (Automatically open, save and close excel).
    You need to recode a marco or write a macro. Why donot you ask in msdn?
    http://social.msdn.microsoft.com/Forums/en-US/home?forum=exceldev&filter=alltypes&sort=lastpostdesc
    example:
    Sub auto_open()
    Application.OnTime Now + TimeValue("00:01:00"), "wswx"
    End Sub
    Sub
    wswx() If Not ThisWorkbook.Saved
    Then ThisWorkbook.Save
    ThisWorkbook.Close
    End Sub
    KR

  • Save and Close excel file opened through OLE

    Hi,
    I have opened an excel file on my desktop and edited it.Now I have to save this file and close it.
    Right now , I am manually saving the file and closing it. So please give the steps to automate the process of saving and closing .
    Please find the code below for opening a file and editing.
    report zkntest2.
    INCLUDE: <line>,
             <icon>,
             <symbol>,
             ole2incl.
    DATA: g_excel_app             TYPE ole2_object,
          g_excel_workbook        TYPE ole2_object,
          g_excel_worksheet       TYPE ole2_object,
          g_excel_usedrange       TYPE ole2_object,
          g_excel_cell            TYPE ole2_object,
          g_excel_return          TYPE ole2_object.
    data :H_MAPL TYPE OLE2_OBJECT,         " list of workbooks
          H_MAP TYPE OLE2_OBJECT,          " workbook
          H_ZL TYPE OLE2_OBJECT,           " cell
          H_F TYPE OLE2_OBJECT.            " font
    CONSTANTS:c_appl(17)              TYPE c VALUE 'Excel.Application'.
    SELECTION-SCREEN BEGIN OF BLOCK blk1 with frame title text-001.
    PARAMETERS p_ofile LIKE rlgrap-filename default 'C:\layout.xls'.
    SELECTION-SCREEN END OF BLOCK blk1.
    CREATE OBJECT g_excel_app c_appl.
    CALL METHOD OF g_excel_app 'Workbooks' = g_excel_workbook.
    CALL METHOD OF g_excel_workbook 'Open'
      EXPORTING #1 = p_ofile.
    SET PROPERTY OF g_excel_app 'Visible' = 1.
    CALL METHOD OF g_excel_app 'Workbooks' = H_MAPL.
    PERFORM FILL_CELL USING  4 9 1 'Kiran'(001).
    PERFORM FILL_CELL USING  5 9 1 'Ref#'(002).
    PERFORM FILL_CELL USING  6 9 1 'Claim#'(003).
    PERFORM FILL_CELL USING  7 9 1 'Location'(004).
    FREE OBJECT g_excel_app.
    FORM FILL_CELL USING I J BOLD VAL.
      CALL METHOD OF g_excel_app 'Cells' = H_ZL EXPORTING #1 = I #2 = J.
      SET PROPERTY OF H_ZL 'Value' = VAL .
      GET PROPERTY OF H_ZL 'Font' = H_F.
      SET PROPERTY OF H_F 'Bold' = BOLD .
    ENDFORM.                    "FILL_CELL

    Try add this code below.
      CALL METHOD OF G_EXCEL_APP 'ActiveWorkbook' = G_EXCEL_WORKBOOK.
      CALL METHOD OF G_EXCEL_WORKBOOK 'SaveAs' EXPORTING #1 = '1.xls'.
      CALL METHOD OF G_EXCEL_WORKBOOK 'Close'.
      CALL METHOD OF G_EXCEL_APP 'Quit'.
      FREE G_EXCEL_APP.

  • Save and close excel file using C#.

    I am not sure why I get the following error for the below code.  Everything seems to work otherwise.
    Error found: System.Runtime.InteropServices.COMException (0x8002000B): Invalid index. (Exception from HRESULT: 0x8002000
    B (DISP_E_BADINDEX))
    Application _application;public void CloseFile(string filename, bool isSaveChanges)
    _application.Workbooks[filename].Close(SaveChanges: isSaveChanges);

    I' work with excel files with connection you can save data and  close connection Easy.
     //connection String for xls file format.
                        if (fileExtension == ".xls")
                            excelConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\"";
                        //connection String for xlsx file format.
                        else if (fileExtension == ".xlsx")
                            excelConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";
                        //Create Connection to Excel work book and add oledb namespace
                        OleDbConnection excelConnection = new OleDbConnection(excelConnectionString);
                        excelConnection.Open();
    DataTable dt = new DataTable();
                        dt = excelConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                        if (dt == null)
                            return null;
                        String[] excelSheets = new String[dt.Rows.Count];
                        int t = 0;
                        //excel data saves in temp file here.
                        foreach (DataRow row in dt.Rows)
                            excelSheets[t] = row["TABLE_NAME"].ToString();
                            t++;
                        OleDbConnection excelConnection1 = new OleDbConnection(excelConnectionString);
                        string query = string.Format("Select * from [{0}]", excelSheets[0]);
                        using (OleDbDataAdapter dataAdapter = new OleDbDataAdapter(query, excelConnection1))
                            dataAdapter.Fill(ds);
    Best Regards
    Hakim.

  • Open file in main vi, write in subvi and close in mainvi

    Hi,
    Im opening a file in the main vi , passing the reference number to the
    write to text file which is located in the subvi and passing the refnum
    out from this vi to the main vi again to close the file.
    But, I always have only the last value of the measurement stored.
    Im getting data from the serial port.
    what am I doing wrong?
    Can someone help me.
    Thanks and regards.

    You probably have forgotten to set the "Write" function to APPEND the data to the file.
    This has nothing to do with where you are writing the file.  Check the inputs for the write function and make sure you set it up to append.
    Shane.
    Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)

  • DMS - Unable to open and Close Excel docs

    Since updating to SP3 :
    1. Excel documents, when opened, show as blank in Excel.
    Activity Log show as Opened
    2. Closing the Doc does not return doc to library
    Activity Log shows nothing .... ie - the doc is still open
    3. I need to Reset the doc to do any further actions on the Doc
    4. After Checking out the Excel Doc, I opened it
    Made no changes to the doc
    Closed it
    GroupWise kicked up an E511 Error during the Close - Unable to REturn
    doc to Library
    I wasn't in DMS mode while editing the doc !!

    It's even worse than I thought
    On a very rare occasion, opening the same problematic Excel doc works
    But most of the time it does not
    Per my previous post, this occurs on both T/S 2003 (with office 2003)
    and T/S 2008 R2 (with Office 2010)
    Steve wrote:
    > GW was installed in 'admin' mode ...
    >
    > The gwappint.inf files all look good
    >
    > I'll keep checking
    >
    >
    > Thing is - this used to work just fine before SP3
    >
    >
    >
    > MarkDissington wrote:
    >
    > >
    > > May be something specific to do with Terminal Server, Excel isn't
    > > ODMA compliant and all the 'integrations' are done through adding
    > > macros in to the core. If Terminal Server is cleaning up those
    > > macros so they don't affect other users then the integrations will
    > > be missing. I don't use Terminal Server, is there an 'admin' mode
    > > for installing software that stores the changes for all users?
    > >
    > > Other than that I'm out of ideas, sorry.
    > >
    > > M

  • Open, Write and Close the file using Powershell

    Hi All,
    I need to create/open a file and write some data into it and close that file.
    Could anyone please help me with this.
    Thanks.

    You don't need to explicitly create, open, or close a file in Powershell.  Here are some ways to write to a file, in addition to New-Item:
    $text = 'Hello World'
    # Create file:
    $text | Set-Content 'file.txt'
    #or
    $text | Out-File 'file.txt'
    #or
    $text > 'file.txt'
    # Append to file:
    $text | Add-Content 'file.txt'
    #or
    $text | Out-File 'file.txt' -Append
    #or
    $text >> 'file.txt'
    Grant Ward, a.k.a. Bigteddy
    The problem with Out-File is that it works like the console. When text is output, it will be truncated if it is wider than the default. So if you are looking for something where you need to store lots of long strings, then you may want to choose a different
    route, or ensure than you specify a width for your output.
    http://technet.microsoft.com/en-us/library/ee176924.aspx
    For example to get 200 characters of width:
    $text | Out-File
    'myfile.txt' -width 200
    I do not know for certain if there is a limit to how wide it can be. I also assume the default is the standard console width (80 characters I believe.)

  • How to convert excel data into OTF and FAX

    Hi All,
    We have a requirement where in we have a smartform output (OTF data) converted into PDF, and an excel sheet, both being sent as email attachments.
    Now, we need to send the content of both the attachments as FAX.
    Since smartform output was OTF convertible, FAX was being sent using 'CONVERT_OTF_AND_FAX' FM.
    Can you let me know, if there is a possible way for manipulating the data that is converted to EXCEL, as OTF, and then FAX it?
    Or else, please suggest me an alternative way to FAX normal data (other than using 'CONVERT_OTF_AND_FAX').
    Thanks in advance,
    RAVI

    Hi All,
    We have a requirement where in we have a smartform output (OTF data) converted into PDF, and an excel sheet, both being sent as email attachments.
    Now, we need to send the content of both the attachments as FAX.
    Since smartform output was OTF convertible, FAX was being sent using 'CONVERT_OTF_AND_FAX' FM.
    Can you let me know, if there is a possible way for manipulating the data that is converted to EXCEL, as OTF, and then FAX it?
    Or else, please suggest me an alternative way to FAX normal data (other than using 'CONVERT_OTF_AND_FAX').
    Thanks in advance,
    RAVI

  • CLOSE EXCEL

    Hi all :
    Please see attach file :
    How can I save and close excel automatically
    Thanks
    Attachments:
    Excel.vi ‏12 KB

    Hi
    I'm having this very problem.I'm trying to open write then save and close and I'm having trouble with the latter. Right now when I run by VI twice, I get a message saying the file is already open and whether I want to open it again, meaning that it wasn't closed in the first place. Is there a Save option rather than a SaveAs option
    I tried the VI uploaded by aeastet but I couldn't get it to work.
    Thanks
    Attachments:
    GS- Write to Excel.vi ‏17 KB

  • How can I write a file and fill it in periods?

    Hi Every body!
    I need help with this.
    I have my aplication(power quality analiser),This VI obtain several varibles and make a lot of calculus and operation, to obtein others parameters in real time so my problem is Save the acquire data and calculus data into a file (similar as a report) every period(custumizable for the user in time units) 
    I mean make a only one file wich is write every period continuously , e.g.  Start my principal VI and this event start the write of file, past one period,make other row or colum into the same file and continue that way until we stop the principal VI.
    How can I make that?
    Thaks very much 
    Best Regards

    Hi,
    assuming you have your trigger (notifier or just periodically) you can append the data to a single record.
    Open the file, set the file position to the end, write the data and close the file.
    Hope this helps

  • CV02N - leaving document after saving and closing excel

    Hi all,
    i change a document (excel file) in transaction cv02n.
    Now i save the file and close excel.
    After that the document is automatically leaving to the initial screen of transaction cv02n.
    How can i avoid that? Customizing?
    Perhaps i want to change the document object itself..
    regards

    Hi,
    i have found the solution.
    Customizing: Define workstation application
    Type: Fr
    Appl. XLS
    AT: 2
    Application: %auto% %NO-LEAVE%
    regards

  • Converting OTF to EXCEL  or PDF to ECXEL  and sending Excel through mail

    Hi ,
    I need a solution for Converting OTF into EXCEL  or PDF into ECXEL  and sending Excel as a attachment to the mail.
    In my current Program I am getting OTF data from script and converting into PDF using Function module ' CONVERT_OTF'
    And sending PDF as a mail attachment using Function module 'SO_NEW_DOCUMENT_SEND_API1' it is working fine but
    My current requirement is I need to send Excel as a mail attachment instead of PDF.
    Hope it is clear for you, please give me solutions with sample code..

    Hi!
    Because OTF is not a grid, like Excel, and PDF can also contain anything, I think it is not possible to convert an OTF, or PDF into an excel spreadsheet.
    You can convert an ALV into excel and send it via email.
    Regards
    Tamá

  • Force file to write into Hard disc

    Hi
    I am using Filewriter to write a XML file which is generated in my program flow to write into HD. and I will pass the file path to a EJB for further processing. The problem is EJB throws XML format error . The file is not written immediately to HD even I flush it.. Please help..

    As long as the writer and the EJB are on the same computer. The data only has to be written to memory. The data is written to memory as soon as you call flush.
    Is it possible the EJB starts to read the data before the file has finished writing?

  • Read data from Excel and write into oracle database

    Hi
    I want  to know how can i read data from excel and write into oracle database using java.Kindly help me out to find a solution.
    Thanks and Regards
    Neeta

    Hai,
    I am suggesting the solution.
    I will try out and let u know soon.
    Make a coma separated file from your excel file.
    Assuming that your requirement allows to make a csv file.
    This file may be passed as an file object to be read by java.Using JDBC you must be able to populate the data base.You can also use String Tokenizer if needed.
    You do not want to  go via sql Loader?
    For reading the excel file itself do you want java?

  • Automation Open and Automation Close (Excel)

    Hi
    I am using ActiveX to write and read from Excel.
    I am writing a program which a case statement is involved. When the boolean is true, the program in the case statment (View Result.VI) will open Excel and display the last save filename file. I run this program individually and not part of the main.vi program.
    It displays the filename but once I close the file, the Excel also closed which I don't want it to do that.
    I run my Main.vi (together with the View Saved Result.vi) and when I want to view the result, the program open Excel, but then, the screen hang and does not load the Excel properly. But when I run the View Saved Result.Vi, it does load properly.
    I was wondering should I use Automation Close f
    or every Excel workbook, worksheet or Invoke nodes which I have used in my program.
    Please look at my JPEG file for understanding.
    Thanks,
    jun
    Attachments:
    Capture_3.jpg ‏53 KB

    I would not call Automation Close for each one. Once you call Automation Close, Excel will exit. That's just how ActiveX is built to work. As long as you want to leave the application open, you shouldn't close the ActiveX Automation controller.
    I would actually suggest gettings the LabVIEW Report Generation Toolset for Microsoft Office. I have found it to be extremely helpful and it's actually quite easy to do what you're wanting to do with this Toolset.
    J.R. Allen

Maybe you are looking for

  • Aging Analysis report for open Items in SD

    Hi , Please give the code snippet for the following case. aging analysis program for open items:- payments not receivecd for 15 days,30 ,60 ,90days imput: custno range sales area days 30,60,90 selection sort by cust no,sales organization output :repo

  • LOV not shown in ViewLink

    I have two view objects based on entitys: EOUsuarioWeb-->users EOGesdusrrol.--> user with rol I create a viewLink matching "EOUsuarioWeb.Usrcodigo" with "EOgesdusrrol.Gescodusr" with one to one relationship. When I run the application module, clic on

  • Can't set up gmail account in 10.7.5 Apple Mail

    Mail on my daughter's MB deals with her Yahoo account splendidly. But when I tried to add her gmail account, it balked. I accessed gmail via the web and turned on IMAP and save changes, then I added the account. The response was that Mail couldn't ac

  • The mystery of the invisible files... that are there...

    OK, so I have a drive connected to my airport, and I'm using it for my itunes library... simple enough... but recently i went poking about in the itunes music folder and many many many many of the folders that itunes is reading music from simply do n

  • Cant open some webpages??

    When i type in a website and hit okay sometimes i get an error saying " Could not open a pop-up because there are to many pages open." anybody know what that means?