I am trying to convert a perfectly good VBA code to Visual Basic using Visual Studio 2008 Express and I am getting an Invalid Cast Exception.
Any help is extraordinarily appreciated. I'm about worn out with this project.
Here's my code:
excel = New Microsoft.Office.Interop.Excel.Application
wb = excel.Workbooks.Add("F:\Work Stuff\Scope Sheet Creator\Scope Sheet Template.xlt")
excel.Visible = True
wb.Activate()
'Dim chbx As CheckBox
'For Each chbx In Me.Controls 'too infinite must fix
Dim chbxArray(2) As CheckBox
Dim chbx As CheckBox
For Each chbx In Me.Controls
If chbx.Checked = True Then
wb.Sheets("Template").activate()
wb.Sheets("Template").select()
wb.Sheets("Template").copy(after:=sheets.Count, Name:="chbx.text")
End If
Next
excel = Nothing
wb = Nothing
End Sub
Jacque
Any help is extraordinarily appreciated. I'm about worn out with this project.
Here's my code:
excel = New Microsoft.Office.Interop.Excel.Application
wb = excel.Workbooks.Add("F:\Work Stuff\Scope Sheet Creator\Scope Sheet Template.xlt")
excel.Visible = True
wb.Activate()
'Dim chbx As CheckBox
'For Each chbx In Me.Controls 'too infinite must fix
Dim chbxArray(2) As CheckBox
Dim chbx As CheckBox
For Each chbx In Me.Controls
If chbx.Checked = True Then
wb.Sheets("Template").activate()
wb.Sheets("Template").select()
wb.Sheets("Template").copy(after:=sheets.Count, Name:="chbx.text")
End If
Next
excel = Nothing
wb = Nothing
End Sub
Jacque