.NET

Reply
Contributor
h.sezenn
Posts: 18
Registered: ‎03-27-2013
Message 1 of 5 (189 Views)

how can I read and write on excel ?

189 Views, 4 Replies
03-28-2013 05:26 AM

28-03-13-q1.jpg

Hello everbody ;

 

I have like this form.

I want to save and update my form on d:\hsezenn.xls.

but when I try this. ı have same eror.

how can I save and update my data on d:\hsezenn.xls ?

_____________________________________________________________________________________
Everything For Duct
*Expert Elite*
arcticad
Posts: 1,285
Registered: ‎06-21-2004
Message 2 of 5 (176 Views)

Re: how can I read and write on excel ?

03-28-2013 06:07 AM in reply to: h.sezenn

Your going to have to show your code and where it's crashing.

 

There are lots of examples on the interwebs.

 

http://lmgtfy.com/?q=read+and+write+excel+vb.net

 

http://www.codeproject.com/Articles/32437/Read-and-Write-Excel-Files

 

---------------------------



(defun botsbuildbots() (botsbuildbots))
*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 3 of 5 (145 Views)

Re: how can I read and write on excel ?

03-28-2013 12:57 PM in reply to: h.sezenn

Take a look ath this topic

http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Names-and-coordinates-in-excel-placin...

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Contributor
h.sezenn
Posts: 18
Registered: ‎03-27-2013
Message 4 of 5 (143 Views)

Re: how can I read and write on excel ?

03-28-2013 01:13 PM in reply to: h.sezenn
Imports Microsoft.Office.Interop
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim oSheet As Excel.Worksheet
        Dim oXLApp As Excel.Application
        Dim wb As Excel.Workbook
        oXLApp = CreateObject("Excel.Application")
        wb = oXLApp.Workbooks.Open("d:\file.xls")
        oSheet = wb.ActiveSheet
        oXLApp.Visible = True
        oSheet.Cells(1, 1).Value = textbox1.text
        oSheet.Cells(1, 2).Value = TextBox2.Text
        oSheet.Cells(1, 3).Value = TextBox3.Text
        oSheet.Cells(1, 4).Value = TextBox4.Text
        wb.Save()
    End Sub
End Class

 when I do this code.

It doesnt work.

ı couldnt save my file.xls

how can I save my file.xls file ?

 

_____________________________________________________________________________________
Everything For Duct
*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 5 of 5 (138 Views)

Re: how can I read and write on excel ?

03-28-2013 01:26 PM in reply to: h.sezenn

Try this code snip to save .xls file:

			'Save workbook
			xlBook.SaveAs(FileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, _
				Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing)
			xlApp.Workbooks.Close()
			xlApp.Quit()
			'or
			' xlApp.Windows[1].Close(false, Type.Missing, Type.Missing);

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.