473,548 Members | 2,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Excel range object into VB.net


I want to place information from an active Excel spreadsheet to a VB.net
form. I just want to place numbers from an Excel cell in a standard
VB.net text box. Does anyone have sample code to demonstrate this
process? I have tried coding the process myself without success. I have
just purchased a 2003 version of VB.net and I am not sure if it is me or
changes in the program. I would like a working example to check my
setup.

Thanks,

Larry Jones
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #1
2 2283
Please forgive my inability to decipher your intent but it is not clear
to me what you are trying to do.

You want to put the contents of one cell or an entire worksheet in a
textbox?

"Larry Jones" <la****@frontie rnet.net> wrote in message
news:la****@fro ntiernet.net:
I want to place information from an active Excel spreadsheet to a VB.net
form. I just want to place numbers from an Excel cell in a standard
VB.net text box. Does anyone have sample code to demonstrate this
process? I have tried coding the process myself without success. I have
just purchased a 2003 version of VB.net and I am not sure if it is me or
changes in the program. I would like a working example to check my
setup.

Thanks,

Larry Jones
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 21 '05 #2
> I want to place information from an active Excel spreadsheet to a VB.net
form. I just want to place numbers from an Excel cell in a standard
VB.net text box. Does anyone have sample code to demonstrate this
process? I have tried coding the process myself without success. I have
just purchased a 2003 version of VB.net and I am not sure if it is me or
changes in the program. I would like a working example to check my
setup.


Can we assume that Excel is also installed on the server? If so, then the
way to
approach this is to use the Excel object library to open the Excel file and
parse it. There's a bit of steep learning curve with Excel but I've done a
lot of Excel VBA work so can help out. This page_load event handler does
something like you're after:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim ExcelApp As New Excel.Applicati on
Dim Workbook As Excel.Workbook =
ExcelApp.Workbo oks.Open("c:\sc ratch\book1.xls ")
Dim Worksheet As Excel.Worksheet = Workbook.Sheets (1)
TextBox1.Text = Worksheet.Range ("A1").Value
Workbook.Close( False)
ExcelApp.Quit()
End Sub

This does the following:

o Creates an Excel application object
o Opens the c:\scratch\book 1.xls
o Finds the first sheet
o Copies the value from cell A1 into the textbox

Along the right lines?

Some issues:

o You'll need Excel installed and therefore a license
o You'll get access denied when you try and creat the Excel app unless the
IIS accounts have the correct access
o How you get the book1.xls uploaded to the server I leave as an exercise
for the reader.

Cheers, Rob.
Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
35500
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet and extract information from specific worksheets and cells. I'm not really sure how to get started with this process. I ran the COM Makepy...
0
3074
by: ImraneA | last post by:
Hi there Many thanks to those people who contributed to this group, helped me greatly. Enclose, my code, hope it helps others :- Public Function Export_Excel_9(tbx1 As Variant, tbx2 As Variant, tbx3 As Variant, tbx4 As Variant, tbx5 As Variant, tbx6 As Variant, tbx7 As
2
2724
by: Jean | last post by:
Hi all, I have a problem automating an Excel object from Access. I have the following fucntion that creates a table in Excel from an Access query: Function CreateTable2(strSourceName As String, _ strFileName As String) As Variant
4
8432
by: IMS.Rushikesh | last post by:
Hi All, I am trying to execute below code but it gives me an COMException ///// Code Start //// public string GetName(Excel.Range range) { try { if (range.Name != null)
22
15319
by: Howard Kaikow | last post by:
There's a significant problem in automating Excel from VB .NET. Reminds me of a problem I encountered almost 3 years ago that was caused by the Norton Auntie Virus Office plug-in. Can anybody reproduce the behavior described below? For this example, I am using Excel 2002 and VS .NET 2002 and VB 6. MSFT KB article 304661 gives a trivial...
4
3114
by: goonsquad | last post by:
I'm writing an Excel Automation app and I'm running to a problem early on with what should be a basic step. Dim oExcel As Object Dim oBook As Object Dim oSheet As Object Dim oRng As Excel.Range oExcel = CreateObject("Excel.Application") oBook = oExcel.Workbooks.Add oSheet = oBook.Worksheets(1)
3
9891
by: | last post by:
I wrote a class in VB.NET to export the contents of a datagrid to Excel. It works perfectly on my machine, but it fails on my customers' PCs that have identical versions of Win XP (SP1) and Excel (SP1) installed. The error is: System.Runtime.InteropServices.COMException(0x800A03EC): Exception from HRESULT: 0x800A03EC. at...
7
2665
by: Alan Roberts | last post by:
Can someone please explain the following for me... I am trying to link to a .NET DLL from Excel. Excel needs to pass a reference to itself to the DLL and then the DLL needs to perform some work on the running instance of Excel via that reference. As an example, a VB DLL to return the path to the current active workbook contains the...
18
8272
by: Frank M. Walter | last post by:
Hello, I have made an small AddIn with udf for excel 2003. I use vs2003. The point of view is the function __T() I call it in excel sheet writing =__T() I am not able to set a value to a given cell. region.Value2="qwe"; //bumm! A exception will be trown. On all PCs with excel. HRESULT 0x800A03EC
16
2678
by: alexia.bee | last post by:
Hi all, In some weird reason, excel instance won;t die if i remove the comment from 4 lines of setting values into struct. here is a snipcode public System.Collections.Generic.List<frmMain.sDBTest> LoadTestSet(string TestSetFile, System.Collections.Generic.List<frmMain.sDBTestDBviewList)
0
7954
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7467
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7805
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6039
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5367
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5085
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3497
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3478
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
755
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.