How to use macro in excel?
Can i get some code to record excell data to vb?
O y, i have project in vb, and i write data in vb, then i transfer it to excell to build chart. This is my code :
Private Sub Command3_Click( )
Set ep = GetObject("C:\D ocuments and Settings\Byon 2007\My Documents\1.xls ")
Set ew = ep.sheets(1)
ew.cells(1, 1) = Label15(0).Capt ion
ew.cells(2, 1) = Label15(1).Capt ion
ew.cells(3, 1) = Label15(2).Capt ion
ew.cells(4, 1) = Label15(3).Capt ion
ew.cells(5, 1) = Label15(4).Capt ion
ew.cells(1, 2) = Label27(0).Capt ion
ew.cells(2, 2) = Label27(1).Capt ion
ew.cells(3, 2) = Label27(2).Capt ion
ew.cells(4, 2) = Label27(3).Capt ion
ew.cells(5, 2) = Label27(4).Capt ion
ew.cells(1, 3) = Text12(0).Text
ew.cells(2, 3) = Text12(1).Text
ew.cells(3, 3) = Text12(2).Text
ew.cells(4, 3) = Text12(3).Text
ew.cells(5, 3) = Text12(4).Text
ew.cells(1, 4) = Label24(0).Capt ion
ew.cells(2, 4) = Label24(1).Capt ion
ew.cells(3, 4) = Label24(2).Capt ion
ew.cells(4, 4) = Label24(3).Capt ion
ew.cells(5, 4) = Label24(4).Capt ion
ew.cells(1, 5) = Label23(0).Capt ion
ew.cells(2, 5) = Label23(1).Capt ion
ew.cells(3, 5) = Label23(2).Capt ion
ew.cells(4, 5) = Label23(3).Capt ion
ew.cells(5, 5) = Label23(4).Capt ion
ew.cells(1, 6) = Label17(0).Capt ion
ew.cells(2, 6) = Label17(1).Capt ion
ew.cells(3, 6) = Label17(2).Capt ion
ew.cells(4, 6) = Label17(3).Capt ion
ew.cells(5, 6) = Label17(4).Capt ion
ep.application. Visible = True
End Sub
what is wrong with this code? Coz the application is not visible when i click the command button.
As u know, i want to change my data in vb and when i click this command button, the application and the chart in excell is visible and change itself according to data in vb....
Thanks for your help.
2 1347 kadghar 1,295
Recognized Expert Top Contributor
How to use macro in excel?
Can i get some code to record excell data to vb?
O y, i have project in vb, and i write data in vb, then i transfer it to excell to build chart. This is my code :
Private Sub Command3_Click( )
Set ep = GetObject("C:\D ocuments and Settings\Byon 2007\My Documents\1.xls ")
Set ew = ep.sheets(1)
ew.cells(1, 1) = Label15(0).Capt ion
ew.cells(2, 1) = Label15(1).Capt ion
ew.cells(3, 1) = Label15(2).Capt ion
ew.cells(4, 1) = Label15(3).Capt ion
ew.cells(5, 1) = Label15(4).Capt ion
ew.cells(1, 2) = Label27(0).Capt ion
ew.cells(2, 2) = Label27(1).Capt ion
ew.cells(3, 2) = Label27(2).Capt ion
ew.cells(4, 2) = Label27(3).Capt ion
ew.cells(5, 2) = Label27(4).Capt ion
ew.cells(1, 3) = Text12(0).Text
ew.cells(2, 3) = Text12(1).Text
ew.cells(3, 3) = Text12(2).Text
ew.cells(4, 3) = Text12(3).Text
ew.cells(5, 3) = Text12(4).Text
ew.cells(1, 4) = Label24(0).Capt ion
ew.cells(2, 4) = Label24(1).Capt ion
ew.cells(3, 4) = Label24(2).Capt ion
ew.cells(4, 4) = Label24(3).Capt ion
ew.cells(5, 4) = Label24(4).Capt ion
ew.cells(1, 5) = Label23(0).Capt ion
ew.cells(2, 5) = Label23(1).Capt ion
ew.cells(3, 5) = Label23(2).Capt ion
ew.cells(4, 5) = Label23(3).Capt ion
ew.cells(5, 5) = Label23(4).Capt ion
ew.cells(1, 6) = Label17(0).Capt ion
ew.cells(2, 6) = Label17(1).Capt ion
ew.cells(3, 6) = Label17(2).Capt ion
ew.cells(4, 6) = Label17(3).Capt ion
ew.cells(5, 6) = Label17(4).Capt ion
ep.application. Visible = True
End Sub
what is wrong with this code? Coz the application is not visible when i click the command button.
As u know, i want to change my data in vb and when i click this command button, the application and the chart in excell is visible and change itself according to data in vb....
Thanks for your help.
It seems fine to me, but i'd do it this way (it might help you): -
Private Sub Command3_Click()
-
dim obj1 as object
-
set obj1 = createobject("excel.application")
-
obj1.workbooks.open("C:\Documents and Settings\Byon 2007\My Documents\1.xls")
-
with obj1.workbooks(1).worksheets(1)
-
.cells(1, 1) = Label15(0).Caption
-
.cells(2, 1) = Label15(1).Caption
-
.cells(3, 1) = Label15(2).Caption
-
.cells(4, 1) = Label15(3).Caption
-
.cells(5, 1) = Label15(4).Caption
-
.cells(1, 2) = Label27(0).Caption
-
.cells(2, 2) = Label27(1).Caption
-
.cells(3, 2) = Label27(2).Caption
-
.cells(4, 2) = Label27(3).Caption
-
.cells(5, 2) = Label27(4).Caption
-
.cells(1, 3) = Text12(0).Text
-
.cells(2, 3) = Text12(1).Text
-
.cells(3, 3) = Text12(2).Text
-
.cells(4, 3) = Text12(3).Text
-
.cells(5, 3) = Text12(4).Text
-
.cells(1, 4) = Label24(0).Caption
-
.cells(2, 4) = Label24(1).Caption
-
.cells(3, 4) = Label24(2).Caption
-
.cells(4, 4) = Label24(3).Caption
-
.cells(5, 4) = Label24(4).Caption
-
.cells(1, 5) = Label23(0).Caption
-
.cells(2, 5) = Label23(1).Caption
-
.cells(3, 5) = Label23(2).Caption
-
.cells(4, 5) = Label23(3).Caption
-
.cells(5, 5) = Label23(4).Caption
-
.cells(1, 6) = Label17(0).Caption
-
.cells(2, 6) = Label17(1).Caption
-
.cells(3, 6) = Label17(2).Caption
-
.cells(4, 6) = Label17(3).Caption
-
.cells(5, 6) = Label17(4).Caption
-
end with
-
obj1.Visible = True
-
End Sub
OK Big Thanks.....
It works.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Savas Ates |
last post by:
i cant delete data from excell which i use as a database with asp .. i
encounter an error report about isam. how can i delete data from excell help
meee!
|
by: alvis |
last post by:
I need to write a windows service that will read a excell spreadsheet and
either update a row in my sql db or insert the row.
My question is how do i read excell spreadsheet row by row in VB dotnet
|
by: Mustafa |
last post by:
I have an ASP script where i am generating the excell sheet dynamically i am
passing some column header text which is long text so i want it to display
it vertically in column (cell).In excell i can do it manually using format
cell , alignment, orientation =90.
the same i want to display through my asp page dynamically.
thanks
Mustafa
|
by: Nick M |
last post by:
Hello All,
Excellent info here Thanks!
I am very new to using access in general and I am on a learning curve.
I'm trying to import an excel workbook (with worksheets) into an access db
via a macro. (I'll get to using VB later on).
What I would like to do is import a single workbook w/three seperate
worksheets into three seperate access...
|
by: Robert Halstead |
last post by:
Hi guys, I have a asp.net web app and it's connecting to
an excell 2003 document (in another folder) via
OleDataAdapter. Everything works and all, it's just that
when I shutdown IE and try to access the excell document,
asp.net seems to still keep it and won't release it.
Excell gives some error saying it can't access it, but
It's when I...
| |
by: Delforce |
last post by:
Hi all,
My application allows you to create a new excel file and then double click
it in the list view to start it in excell. If the excell file is an existing
one then I can start it now problem.
The problem is when I create a new excel file in my application and try and
double click it excell starts and has the name of my newly created...
|
by: glibo |
last post by:
I am trying to change the tab name when i open a excell spread sheet on the run time in c#.
I changed it in the code:
Response.AddHeader("content-disposition","filename=" + sFileName + ".xls");
But it works only on save mode but on the display mode still display the name of the page i am calling this excell spread sheet, in other words i see...
|
by: Ali Rizwan |
last post by:
Hi all,
I m creating a database. The data for database will fetched from an excell sheet. Now how can i read an excell sheet and update my database with that excell sheet.
Or
I want to show all records of excell sheet in a listbox having a title of speecific text like "Names".
Thanx
>> ALI <<
|
by: asedt |
last post by:
With my Excel macro and two text files I want to create a new textfile containing the first textfile then text from the sheet and then the second textfile.
My problem is that i don't know how to append the second textfile.
Sub mysub()
Dim TempString As String
'Open the first file
Dim fileA As Integer
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |