473,387 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How add data to excel without overwrite the data or the design in it

I using visual basic 2010 and I want to extract the data I had insert in the exe.file to excel without overwrite the data or design of it. Below is the code I use

Expand|Select|Wrap|Line Numbers
  1. Dim oExcel As Object
  2.             Dim oBook As Object
  3.             Dim oSheet As Object
  4.             Dim sNWind As String
  5.             Dim conn As New ADODB.Connection
  6.             Dim rs As ADODB.Recordset
  7.             sNWind = _
  8.                "D:\Book1.xls"
  9.             conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
  10.                sNWind & ";")
  11.             conn.CursorLocation = adUseClient()
  12.             rs = conn.Execute("Orders", , adCmdTable)
  13.  
  14.             'Start a new workbook in Excel
  15.             oExcel = CreateObject("Excel.Application")
  16.             oBook = oExcel.Workbooks.Add
  17.  
  18.             oSheet = oBook.Worksheets(1)
  19.  
  20.             oSheet.Range("F1").Value = "MOQ:"
  21.             oSheet.Range("G1").Value = t
  22.             oSheet.Range("I1").Value = Format(((Val(i) * Val(j) * Val(k) * ab + Val(a) * Val(b) * Val(c) * aa) * (Val(ag) + Val(ah) + 0.15 + 0.3) + u + u * 0.12) + ((Val(i) * Val(j) * Val(k) * ab + Val(a) * Val(b) * Val(c) * aa) * (Val(ag) + Val(ah) + 0.15 + 0.3) + u + u * 0.12) * 5 / 100 + (((Val(i) * Val(j) * Val(k) * ab + Val(a) * Val(b) * Val(c) * aa) * (Val(ag) + Val(ah) + 0.15 + 0.3) + u + u * 0.12) + ((Val(i) * Val(j) * Val(k) * ab + Val(a) * Val(b) * Val(c) * aa) * (Val(ag) + Val(ah) + 0.15 + 0.3) + u + u * 0.12) * 5 / 100) * 10 / 100, "0.0000")
  23.             oSheet.Range("H1").Value = "Price:"
  24.             If f = "Sheet in roll" Then
  25.                 oSheet.Range("I2").Value = c & "mm " & "x" & (a - 30) / Val(cc) & "mm " & "x" & b & "meter  " & ComboBox5.SelectedItem & "UP"
  26.                 oSheet.Range("E4").Value = "L(m)"
  27.  
  28.             Else
  29.                 oSheet.Range("E4").Value = "L(mm)"
  30.  
  31.                 oSheet.Range("I2").Value = c & "mm " & "x" & (a - 30) / Val(cc) & "mm " & "x" & b & "mm   " & ComboBox5.SelectedItem & "UP"
  32.             End If
  33.             oSheet.Range("F2").Value = ComboBox1.SelectedItem & " colour " & f & " Bag   " & h
  34.             oSheet.Range("B8").Value = "Process"
  35.             oSheet.Range("H2").Value = "Size"
  36.             oSheet.Range("A1").Value = "Company Name"
  37.  
  38.             oSheet.Range("C1").Value = TextBox1.Text
  39.             oSheet.Range("A2").Value = "Sign By: "
  40.             oSheet.Range("C2").Value = TextBox2.Text
  41.             oSheet.Range("A3").Value = "No."
  42.             oSheet.Range("B3").Value = "Particulars"
  43.             oSheet.Range("C3").Value = "Dimension"
  44.             oExcel.Quit()
  45.  


Thanks in advance.
Waiting for your answer.
Sep 7 '15 #1
0 926

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Fred | last post by:
Hi. How do I import while mapping an excel table to an access table please??? I've searched around and all I can find is a software product or code that does the same thing as the access...
4
by: Gary Wright | last post by:
I have an Access 2K database split into front and back. Quite often the users want to do some data analysis that I have not created a report for so they want to export some subset of the data into...
11
by: Hi5 | last post by:
Hi, I am new to access I usedto work in Oracle and Mysql. I am after a way that enables me to populate a database I designed in access with lots of data which can be sorted in excel sheets, ...
0
by: popsovy | last post by:
Hi I have a question about whether Data Binding can facilitate the process of saving data in a web application I learned that you can data bind information from a number of different data...
1
by: Pk | last post by:
Hi, I have an data in multiple excel worksheet which i wan to upload into sql server through asp code. Please help me how can i use server.createobject("excel.application") help me its...
1
by: iamset via SQLMonster.com | last post by:
We are using SQL Server 2000 Standard ed, sp4 on Server 2000 Advanced. We have one table that is three times as large as the rest of the database. Most of the data is static after approximately...
0
by: hd95 | last post by:
I am trying to insert to an Excel 12 spreadsheet through VB/ADO .Net 2.0 Here's my connection string Dim connectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data...
2
Procman
by: Procman | last post by:
I'm using Office 2003 and have done some programming in Access, but not in Excel. - I have an Access DB with a form to enter all receipts and invoices. I use Excel to view the data as a...
0
by: ggats11 | last post by:
Can c# talk to excel without vsto and ifso how do I code it?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.