|
-
September 10th, 2009, 05:07 PM
#1
[RESOLVED] Copy Sheet & Name checkbox.text
I am trying to use a vb window app to open an existing excel workbook, and for every checkbox that is checked on the form copy the existing worksheet and name it with the text of the checkbox when the button is clicked
Please help
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
excel = New Microsoft.Office.Interop.Excel.Application
'sheets = New Microsoft.Office.Interop.Excel.Worksheet
wb = excel.Workbooks.Add("F:\Work Stuff\Scope Sheet Creator\Scope Sheet Template.xlt")
excel.Visible = True
wb.Activate()
For Each ctrl As Control In Me.Controls
If (TypeOf ctrl Is CheckBox AndAlso CType(ctrl, CheckBox).Checked) Then
wb.Sheets("Template").activate()
wb.Sheets("Template").select()
wb.Sheets("Template").copy(after:=sheets.Count, Name:=CStr(ctrl.Text)) 'error use new
End If
Next
excel = Nothing
wb = Nothing
End Sub
Last edited by Shuja Ali; September 11th, 2009 at 01:54 PM.
Reason: Added code tags
-
September 11th, 2009, 08:26 AM
#2
Re: Copy Sheet & Name checkbox.text
Please use code tags to make your code better legible.
Also it seems to be VB.NET, so you are rather wrong here.
-
September 11th, 2009, 01:55 PM
#3
Re: Copy Sheet & Name checkbox.text
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|