URGENT Please help! create excel workbook & 3 spreadsheets

Hi Im stuck with generating some excel files in a directory folder using VB.NET

Please help me to:
2. Create an excel workbook (Im using Office 2003)
3. Create 3 named sheets in the workbook

Just looking for some code that works & dont care if its messy as long as it works

Thanks heaps!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hello craigdev,

used a button on a form for this
Public Class Form1

    'source: http://dotnetjunkies.com/WebLog/dinakar/articles/16282.aspx
    Function CreateNewFolder(ByVal Path, ByVal NewFolderName)

        Dim objFSO As Object
        objFSO = CreateObject("Scripting.FileSystemObject")
        Dim FullPath As String
        FullPath = Path & NewFolderName
        If Not objFSO.FolderExists(FullPath) Then
            CreateNewFolder = True
            CreateNewFolder = False
        End If
        objFSO = Nothing

    End Function

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim xlObj As Object, mysheet As Object
        Dim strSheet As String, sheetCount As Integer
        Dim strPath As String, strFolder As String

        strPath = "c:"
        strFolder = "myfolder"
        CreateNewFolder(strPath, strFolder)
        xlObj = CreateObject("Excel.Application")
        xlObj.visible = True
        ' now we first need a count of the default sheets on this pc
        sheetCount = xlObj.workbooks(1).sheets.count
        Select Case sheetCount
            Case 1
                xlObj.workbooks(1).sheets(1).name = "MySheet1"
                mysheet = xlObj.workbooks(1).sheets.add()
                mysheet.name = "MySheet2"
                mysheet = xlObj.workbooks(1).sheets.add()
                mysheet.name = "MySheet3"
            Case 2
                xlObj.workbooks(1).sheets(1).name = "MySheet1"
                xlObj.workbooks(1).sheets(2).name = "MySheet2"
                mysheet = xlObj.workbooks(1).sheets.add()
                mysheet.name = "MySheet3"
            Case 3
                xlObj.workbooks(1).sheets(1).name = "MySheet1"
                xlObj.workbooks(1).sheets(2).name = "MySheet2"
                xlObj.workbooks(1).sheets(3).name = "MySheet3"
        End Select
    End Sub
End Class

hope this helps a bit

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
craigdevAuthor Commented:
Awesome!!! Thanks Buddy!
good luck! and thanks for the grade :)
craigdevAuthor Commented:
... just another quick q,

how to I save the workbook to the folder, in the example above, C:/myfolder?
craigdevAuthor Commented:
nah its fine, all finished, CHEERS
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.