LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Delete Row from Excel Report while report generation

Solved!
Go to solution

Hello all,

 

I am trying to Remove entire rows from the excel report during report generation in excel but I am not able to do this. Here I attach one excel template, In this I want to remove row no 3 to 5 how can I do this. I am using LabVIEW 8.6 with Report Generation Toolkit For Microsoft Office 1.1.3

 

 Thanks and Regards..

Greeting from India,
Malhar
0 Kudos
Message 1 of 6
(6,872 Views)
Solution
Accepted by topic author Malhar

If there is no report generation function for simple operations like this, then use the VBA macros pallette to run this snippet of code:

 

' delete all the rows between the two rows inclusively
Sub DeleteRows(intTopRow As String, intLastRow As Integer)
    Range(Cells(intTopRow, 1), Cells(intLastRow, 1)).EntireRow.Delete xlShiftUp
End Sub

Use Excel Import Module to load the .bas file then Excel Run Macro with the parameters 3 and 5.  Check your security settings if you get an error running the macro.

 

Michael Munroe, CLD, CTD, MCP
Automate 1M+ VI Search, Sort and Edit operations with Property Inspector 5.1, now with a new Interactive Window Manager!
Now supports full project automation using one-click custom macros or CLI.
Message 2 of 6
(6,852 Views)

Thanks Michae,

 

I got the solution but one more thing i would like to include that, is there any way to change macro secutity settings of excel from LabVIEW..??

Hope it could be..wait for your positive replay.. thank you once again.

 

Malhar Chaniyara

 

Greeting from India,
Malhar
0 Kudos
Message 3 of 6
(6,834 Views)

No, you cannot programmatically change the Excel securty settings.  If you need to distribute your application and cannot set the security, I suggest that you create you own activeX VI for this purpose. 

 

Start with the Excel Insert Cells.vi in the Report Generation Toolkit and modify as per the VBA code.  Use -4162 for the shift parameter on delete.

Michael Munroe, CLD, CTD, MCP
Automate 1M+ VI Search, Sort and Edit operations with Property Inspector 5.1, now with a new Interactive Window Manager!
Now supports full project automation using one-click custom macros or CLI.
0 Kudos
Message 4 of 6
(6,807 Views)

There Is an other solution, I think is simplier, I already test it and works fine.

 

First I save a copy of the "Excel Insert Cells.vi" (installed with the report generation Tool Kit) and rename it as "Excel Remove Cells.vi", then in the "Excel Remove Cells.vi", I just modify the methods used by the original function in order to change the "insert" to "remove" action and that is all.

 

A copy of the "Excel Remove Cells.vi" is attached

 

Best Regards

Alfonso Jiménez

 

 

0 Kudos
Message 5 of 6
(6,408 Views)

Alfonso,

 

I was trying to do this same thing. However, when I open the 'Excel insert cells' VI, the 'save as' option is greyed out. I can't save a separate, remaned copy. I tried copying and pasting the code into a new VI but got broken wires. It must be something to with the reference?

 

I also tried to use the code that you had attached, but one of the subvis was missing - 'Generate Report Set Modified Data.'

 

Can you offer any advice?

 

Thanks,

 

Will

0 Kudos
Message 6 of 6
(5,400 Views)