Jump to content

Use of Variant causes Excel not to close


Recommended Posts

Hi,

I've got a program that converts Excel worksheets into 2D arrays of strings.

I'm having a problem where Excel does not close if I use the 2D array for anything.

post-18058-039896600 1282763708_thumb.jp

If I do not use the array, Excel closes fine.

post-18058-094061200 1282763701_thumb.jp

I've attached Labview 8.6 files of both the working and nonworking versions. It would be great if someone can tell me what I've missed here. Suggestions for simpler ways to do this are also welcome, as I'm a little new at ActiveX.

Thanks!

Excel Test Works.vi

Excel Test Fails.vi

Edited by Random User
Link to comment

Hi,

It seams that you have a type mismatch here. I have not noticed this behavior before, but LabVIEW ignores the conversion if no output is wired. If a scaler (single string) is wired to the type input of the "variant to data" function, there are no errors. This could be caused because there is no data on the variant "value2". I usually use the report generation tool kit. It has functions for this kinda of work.

Mike

  • Like 2
Link to comment
If a scaler (single string) is wired to the type input of the "variant to data" function, there are no errors. This could be caused because there is no data on the variant "value2".

Right - you're trying to read a single Excel cell into a 2 dimensional array - that's not going to work. Also, I'm guessing that there's an error on the error cluster after the convert to variant VI, which might be causing something downstream (prbably the Workbook|Close method) to not execute - that's why Excel isn't closing. I suggest you rearchitect your code a little to use the merge errors VI, instead of chaining all the errors into one wire.

  • Like 1
Link to comment

Ok, you guys have helped me figure this out. What I'm doing works in the general case since I'm converting a range of cells to an array of strings (instead of a single cell to an array). But it's true that one of the worksheets in my workbook causes a type mismatch...must be some cell with a weird format or something. Removing that particular worksheet allows my program to run normally.

Thanks!

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.