LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with quitting Excel with activex (save-dialog)

Solved!
Go to solution

Hello.

 

I have following question.

I have a VI that writes data from measurement devices into an excel file. Afterwards I want to change the order of the entries with the help of activex.

All that works fine, but when I quit excel the save-dialolg always pops up. I searched this board for possible solutions and experimented quite a bit but I still get one dialog at the end.

Well, now at least it is only one and not multiple ones. The loop in my the implementation for the data manipulation might be the cause, but if it is it, i don't know why or how to solve it. But maybe it is something different. Anyway, I cannot find the reason.

Some help would be really appreciated .

 

Thank you very much in advance.

 

Regards

CD

0 Kudos
Message 1 of 12
(4,088 Views)

Why are you writing a True to the Property Node Workbook Saved?  I'm not sure, but I think that property is one to read to see if a workbook has been saved.

 

You know the workbook saved because you just did that.  I'm thinking that by writing a True to the Workbook.Saved property, you are actually changing the workbook and causing the Need to Save flag to be reset thus forcing the Save dialog to appear when you go to close the workbook.

0 Kudos
Message 2 of 12
(4,083 Views)

First, thank you for your answer.

 

Why did I set it? Because I thought maybe LabVIEW didn't set that property correctly and that might cause the problem.

I removed it again and started a test run which lead to the following result.

Instead of one save dialog popping up, now three are popping up (one after another not simultaniously).

0 Kudos
Message 3 of 12
(4,074 Views)

I see you have a workbooks close as well.

 

Are there multiple workbooks open in Excel when it tries to close them?  Even if there are workbooks that you didn't actually change things in, they could possibly get their "dirty" bit set due to some background process like a recalculation of formulas.  I know I have some spreadsheets that have a large amount of VB programming in them, and just by opening the spreadsheet and closing, it asks me to save changes.  Maybe something like that is happening here as well.

 

Try disabling the save workbooks function and see what happens.  Try running in highlight execution and see which functions cause the dialog boxes to pop up.

0 Kudos
Message 4 of 12
(4,058 Views)

The workbook saved property will be true if no changes were made since the last time the workbook was saved. Because this property is read/write you can set it to TRUE even if the workbook have been change. In this case there is no need to use this property especially if you want the changes to be saved.

 

You should also disable the autoindexing of the workbook reference coming out of the for loop. Another thing, what's the purpose of making the application visible just before quitting it?

 

 

Ben64

0 Kudos
Message 5 of 12
(4,053 Views)

Thank you for yout comments and suggestions.

I will try them righ away.

 

As for your questions.

-No, actually there should be only one worksheet and one workbook open.

-Simply for debugging. But true, I could just have set visible on true at the beginning. That would have been smarter.

0 Kudos
Message 6 of 12
(4,041 Views)

OK. In the attachment is a picture of the modifications.

Now I have to two problems.

First, after running it in highlight modus, I now know the dialog pops up at the _Workbook.close invoke node. Despite setting true to SaveChanges.

Second, I now get an error code -2147352565 - unknown error at invalid index. and nothing gets saved.

0 Kudos
Message 7 of 12
(4,033 Views)

Do not connect the Filename input when you use the  _Workbook close method since there is already a filename associated with the workbook. I think this will get rid of the popup. For the error, where does it originate?

 

Ben64

0 Kudos
Message 8 of 12
(4,015 Views)

Try doing a Save method on the workbook before doing the Close method and see if it behaves any better.

0 Kudos
Message 9 of 12
(4,013 Views)

Hi again. And thank you for your time and suggestions.

 

I tried both things you suggested, alone and in combination, but still the result is the same, the save dialog appears.

 

As for the error. I think that is unrelated to this problem. It somehow appears a bit randomly. I have to put some further investigation into that one tomorrow. But besides that, I still don't know why excel is not doing what I want it to do.

 

0 Kudos
Message 10 of 12
(3,995 Views)