creating a Excell worksheet from Vb

Hello
I want to create a new excel worksheet dynamically from within my application.What I need to do is hand in Product name ,barcode  and a quantity field .Also I have to hand in a formula for a quantity total Does any body have a sample which could show me how this is done.
Regards T
visualbasicAsked:
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.

manojaminCommented:
0
jfleminCommented:
Dim ExcelApp As Excel.Application
    Dim ExcelBook As Excel.Workbook
    Dim ExcelSheet As Excel.Worksheet
   
    Screen.MousePointer = vbHourglass
    Set ExcelApp = New Excel.Application
        Set ExcelBook = ExcelApp.Workbooks.Add
            Set ExcelSheet = ExcelBook.Worksheets.Add(, , , xlWorksheet)
                ExcelSheet.Cells(1, 1).Value = "Added through VB"
                ExcelSheet.Name = "My Sheet Name"
                ExcelSheet.SaveAs "C:\Temp\VbExample.Xls"
            Set ExcelSheet = Nothing
        ExcelBook.Close
        Set ExcelBook = Nothing
    ExcelApp.Quit
    Set ExcelApp = Nothing
    Screen.MousePointer = vbNormal
0
manojaminCommented:
jflemin,
Basically it same as the link I provided...

visualbasic,
jflemin code is fine, if you want to put formula in A2 replace following line

ExcelSheet.Cells(1, 1).Value = "Added through VB"

with

ExcelSheet.Cells(1, 1).Value = "0"
ExcelSheet.Cells(2, 1).Formula = "=A1 + 1"

This way, you will have value 0 in A1 and value 2 in A2

0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

eyaltilCommented:
Code as above
0
manojaminCommented:
eyaltil,

what was that about???
0
visualbasicAuthor Commented:
: manojamin
Could you mail me an wed so I can give you the 100 points
0
manojaminCommented:
an wed?

what is that?

How do I mail you? I don't have your e-mail address!

I guess you will have to reject eyaltil answer in order for me to provide you answer!!

0
manojaminCommented:
an wed?

what is that?

How do I mail you? I don't have your e-mail address!

I guess you will have to reject eyaltil answer in order for me to provide you answer!!

0
manojaminCommented:
Here is the answer to get the points!!

jflemin,
Basically it same as the link I provided...

visualbasic,
jflemin code is fine, if you want to put formula in A2 replace following line

ExcelSheet.Cells(1, 1).Value = "Added through VB"

with

ExcelSheet.Cells(1, 1).Value = "0"
ExcelSheet.Cells(2, 1).Formula = "=A1 + 1"

This way, you will have value 0 in A1 and value 2 in A2



0

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
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 Classic

From novice to tech pro — start learning today.