LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How can i automatically increases the cell index in Excel ?

You do not need to set the format of the cell to Date/Time to display a time string.
Since you'll send date and time as a string it is even better to make it a text cell. Because cells formatted as date/time will be treated different by Excel. Nothing wrong with CVI.
Thats why you get a wrong date value in your cell.

S. Eren BALCI
IMESTEK
0 Kudos
Message 11 of 15
(1,364 Views)

First of all, I recommend you to use functions from ExcelRpt library.
These functions' name start with "ExcelRpt_". They are simpler and better documented.

Can you try ExcelRpt_WorkbookSave, please?
You can also save while closing the workbook using ExcelRpt_WorkbookClose(handle, 1);

Hope this helps.

S. Eren BALCI
IMESTEK
0 Kudos
Message 12 of 15
(1,366 Views)

Some suggestions on your sample project.

First of all, you must match every object allocation with a correspondent deallocation, otherwise some processes may remain pending  (you may observe them in windows task manager) and give problems in the future. I modified your sample project this way and on my machine all is working well without errors using Excel_WorkbookSave command.

As per the attachment, I don't know if RAR files are allowed on this board: I always attached ZIP files without problems.

Last, it's not necessary to add debug files to the attached file (all _dbg files and the cvibuild directory): they unnecessarily increase attachment size adding informations that are rebuild every time you run the project.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 13 of 15
(1,352 Views)
Hi Roberto and ebalci,

First of all, I want to say that You are very kind 🙂 . U helped me a lot .

And i'm sorry for late replying because i was exhausted and needed a little off-work time.

So come back to my application,I still have some questions to ask:

+in the modified files by Roberto, U placed these commands in the fuction MAIN :

    if (ExcelWorksheetHandle) CA_DiscardObjHandle (ExcelWorksheetHandle);
    if (ExcelWorkbookHandle) {
        ExcelRpt_WorkbookClose (ExcelWorkbookHandle, 1);
        CA_DiscardObjHandle (ExcelWorkbookHandle);
    }
    if (ExcelHandle) {
        ExcelRpt_ApplicationQuit (ExcelHandle);
        CA_DiscardObjHandle (ExcelHandle);
    }

I think i understand their functions but still not sure about how it works in the whole program (in run-time ,i mean) .

Mean while,in the "CVICALLBACK ExcelSendcall" function, it is easier, in the first part of this function , we run an Excel application so in the end we close it.

However, In the MAIN , i cann't understand the initative condition.

+ and the 2nd issue is about menu bar.If i place this line in the MAIN function :

 childPanel1=LoadPanel (panelHandle, "1.uir", PANEL_2);

and then in the callback function of the submenu item ; i place these

 DisplayPanel (childPanel1);
 RunUserInterface ();
 DiscardPanel (childPanel1);

The result is I just can call this panel 1 time at all. The next time is :"Panel,pop up or menubar handle is invalid".

Then i tried to replace and put "childPanel1=LoadPanel (panelHandle, "1.uir", PANEL_2);" in the callback function, right above the DisplayPanel... and it works properly .

I did read Roberto's reply about a same problem but still try to figure out its mechanism ?

Really Appreciate !

🙂

P/s : All i have is only some examples in CVI folder but with these thing, i just can learn the copy-paste method.Fortunately, i found these forum and got many helps from Roberto and elbaci .I am very appreciate about that and if U found some of my question is such "silly" questions ,please forgive me !

Many thanks !

0 Kudos
Message 14 of 15
(1,315 Views)
Looking at your program I noticed that you were connecting to excel and opening the workbook in several places, but you not always closing it and discarding the activex references / objects, so I modified the project according to these guidelines:
1. Connect to excel and open the workbook only once. Keep the handles in global variables
2. Disconnect when no more needed. Reset handles to zero after discarding
3. At program close, be sure to discard all objects remain allocated, based on the handles not reset to zero
This way I am sure that I leave a clean situation when my application ends up.
 
As per your second question, you must keep in mind that a resource, be it a panel or a menu bar, must be loaded in memry before you can use it. In your callback you first display a panel (supposely you have loaded it before), next you discard it: from this moment on the panel handle is invalid since it references an object that no long is in memory. If you need to reuse a panel but do not want to have it visible on the screen you can use HidePanel instead of DiscardPanel.
 
Last but not least, be sure to have only one RunUserInterface only in all your program: the preence of more that one of them can lead you to unpredictable program behaviour.


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 15 of 15
(1,309 Views)