Update Cell in Excel Sheet on Network via VB?

Hi,

I have a form with a textbox contianing a value and a button.

I'm looking to have the button copy the value of TextBox1.Text to Sheet 1, Cell B2 of my spreadsheet.

The spreadsheet is located at the below link.

\\test\testing\test.xls

Can anyone show me how to copy the vlaue of the Textbox to this sheet?

Thanks,

Paul.
m0tSiEAsked:
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.

GuitarRichCommented:
You could use the Excel automation objects to do it. Here is tutorial on creating a worksheet - it shouldn't be too hard to modify it to open an existing one and change it http://www.vbdotnetheaven.com/UploadFile/ggaganesh/ExcelSpreadsheet04182005093012AM/ExcelSpreadsheet.aspx

0
omegaomegaDeveloperCommented:
Hello, m0tSiE,

The snippet contains a trivial example.  Just change the location of the Workbook to "\test\testing\test.xls" for your case.

Cheers,
Randy

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
 
        Dim xlaTest As Excel.Application = CType(CreateObject("Excel.Application"), Excel.Application)
        Dim wbkTest As Excel.Workbook = xlaTest.Workbooks.Open("D:\Tests\VB Trials\ExcelTests\TestWorkbook.xls")
        Dim wshTest As Excel.Worksheet = DirectCast(wbkTest.Worksheets("Sheet1"), Excel.Worksheet)
        wshTest.Range("B2").Value = Me.TextBox1.Text
        wbkTest.Close(SaveChanges:=True)
        xlaTest.Quit()
 
    End Sub

Open in new window

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
m0tSiEAuthor Commented:
Worked great! Cheers!
0
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.