LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding a sheet in excel with a specific name.

How can I add a sheet in excel with a specific name after an existing sheet with an unknown name.
0 Kudos
Message 1 of 11
(8,431 Views)
Just use the Sheets->Add function and wire the existing sheet index into the After input.

From the Workbook refnum:
Wire Property Node - Workbook->Sheets
Wire Method Node - Sheets->Add, wire the After input
Convert the Variant from Add into a WorkSheet type
Wire Property Node - WorkSheet Name
Michael Munroe, CLD, CTD, MCP
Automate 1M+ VI Search, Sort and Edit operations with Property Inspector 4.1, now with a new Interactive Window Manager!
Review the top 24 Impossible with LabVIEW Categories
Message 2 of 11
(8,431 Views)
Thanks for the help. That worked great. Now I need to copy the content of the first sheet and paste it in the newly created sheet. Any ideas?

Jonathan
0 Kudos
Message 3 of 11
(8,431 Views)
It is easier to duplicate an existing sheet than to add a blank sheet and copy the entire contents.

To duplicate sheet:
Use the Sheets->Item(x) to select the sheet
Convert the output to a WorkSheet
Use method WorkSheet->Copy, wire the index into After
Use Sheets->Item(y) again to select the new sheet

To copy contents to the new sheet:
Wire target's WorkSheet->Range("A1") to specify destination
Use Sheets->Item(x) to select the source sheet
Convert source to WorkSheet
Wire source to property WorkSheet->UsedRange
Wire to method Range->Copy, wire target range to Desination input
Michael Munroe, CLD, CTD, MCP
Automate 1M+ VI Search, Sort and Edit operations with Property Inspector 4.1, now with a new Interactive Window Manager!
Review the top 24 Impossible with LabVIEW Categories
0 Kudos
Message 4 of 11
(8,432 Views)

Hello Michael,

I want to duplicate the sheet in my workbook. I built a VI as directed by you, but it is not duplicating the sheet. I am using Labview 8.2. I have attached my VI, in which "source" is the sheet to be duplicated and "target" is where the sheet is to be copied. I am liitle bit unsure about the flow/logic of block digram. Where is my mistake ?

Thanking you

Pranav

0 Kudos
Message 5 of 11
(8,007 Views)
I believe this thread will help you find a solution:

http://forums.ni.com/ni/board/message?board.id=170&message.id=53394&requireLogin=False

Cheers!
0 Kudos
Message 6 of 11
(7,992 Views)

Thanks for reply. However, I have modified my Duplicate sheet.VI as shown in new attachment. Please give feedback, whether it is ok or not.

Regards

0 Kudos
Message 7 of 11
(7,981 Views)
Your VI looks good, pranav. Does it accomplish everything you'd like, or is there more functionality that we can help you with?
Amanda Howard
Americas Services and Support Recruiting Manager
National Instruments
0 Kudos
Message 8 of 11
(7,971 Views)
Hello, Thanks for your feedback.  I wanted to create a duplicate sheet of a specified sheet in the same workbook with diffrent name keeping original intact. I have tested it and found ok.
 
In th main VI, the block diagram functions used after this sub VI, prompt user to make necessary changes in newly generated sheet as required by the application and then save it again. For example, original sheet is "Acquisiton", which is duplicated with the name "Correction" keeping Acquisition intact. After this, Main VI will remain in wait state untill user makes necessary changes in "correction" sheet and press "save & exit" button.
 
Pranav
0 Kudos
Message 9 of 11
(7,961 Views)

I'm getting the error -2146827284 with no description when using the Sheets.Add with an U16 number wired to the After field. When I try using the Sheets.Add without the field wired I get no error. Is there any proper way I'm supposed to be converting the variant?

0 Kudos
Message 10 of 11
(7,363 Views)