Hello all,
Could anybody help me referencing individual cells in excel? I don't know
what I do wrong here (but I'm not familiar with excel vba) (Microsoft Excel
10.0 Object library is referenced)
Any help very much appreciated
Thanks
Ronny
Private Sub btnTargetAffGro upEmailImport_C lick()
Dim MyXL As Object
Dim ExcelWasNotRunn ing As Boolean
On Error Resume Next ' Defer error trapping.
Set MyXL = GetObject(, "Excel.Applicat ion")
If Err.Number <> 0 Then ExcelWasNotRunn ing = True
Err.Clear
DetectExcel ' I HAVE PASTED THIS FUNCTION BELOW .....
Set MyXL = GetObject("U:\M IJNTEST.XLS")
MyXL.Applicatio n.Visible = True
MyXL.Parent.Win dows(1).Visible = True
'HERE I HAVE TO REFERENCE THE INDIVIDUAL CELLS
MyXL.cell(2, 2) = "Een"
MyXL.cell(2, 3) = "Twee"
MyXL.cell(2, 4) = "Drie"
MyXL.cell(2, 5) = "Vier"
If ExcelWasNotRunn ing = True Then
MyXL.Applicatio n.Quit
End If
Set MyXL = Nothing ' Release reference to the
' application and spreadsheet.
End Sub
Public Function DetectExcel()
' Procedure dectects a running Excel and registers it.
Const WM_USER = 1024
Dim hWnd As Long
' If Excel is running this API call returns its handle.
hWnd = FindWindow("XLM AIN", 0)
If hWnd = 0 Then ' 0 means Excel not running.
Exit Function
Else
' Excel is running so use the SendMessage API
' function to enter it in the Running Object Table.
SendMessage hWnd, WM_USER + 18, 0, 0
End If
End Function 2 3305
From my file:
See below my SIG
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications re******@pcdata sheet.com www.pcdatasheet.com
Refer To A Specific Cell In An Excel Worksheet
ObjWkb.Workshee ts(1).Cells(Row , Col).Value
Row = Integer, specifying the row number
Col = Integer, specifying the column number
"Ronny Sigo" <ro********@sky net.be> wrote in message
news:40******** *************** @feed0.news.be. easynet.net... Hello all, Could anybody help me referencing individual cells in excel? I don't know what I do wrong here (but I'm not familiar with excel vba) (Microsoft Excel 10.0 Object library is referenced) Any help very much appreciated Thanks Ronny
Private Sub btnTargetAffGro upEmailImport_C lick() Dim MyXL As Object Dim ExcelWasNotRunn ing As Boolean On Error Resume Next ' Defer error trapping. Set MyXL = GetObject(, "Excel.Applicat ion") If Err.Number <> 0 Then ExcelWasNotRunn ing = True Err.Clear DetectExcel ' I HAVE PASTED THIS FUNCTION BELOW ..... Set MyXL = GetObject("U:\M IJNTEST.XLS")
MyXL.Applicatio n.Visible = True MyXL.Parent.Win dows(1).Visible = True 'HERE I HAVE TO REFERENCE THE INDIVIDUAL CELLS MyXL.cell(2, 2) = "Een" MyXL.cell(2, 3) = "Twee" MyXL.cell(2, 4) = "Drie" MyXL.cell(2, 5) = "Vier"
If ExcelWasNotRunn ing = True Then MyXL.Applicatio n.Quit End If
Set MyXL = Nothing ' Release reference to the ' application and spreadsheet.
End Sub
Public Function DetectExcel() ' Procedure dectects a running Excel and registers it. Const WM_USER = 1024 Dim hWnd As Long ' If Excel is running this API call returns its handle. hWnd = FindWindow("XLM AIN", 0) If hWnd = 0 Then ' 0 means Excel not running. Exit Function Else ' Excel is running so use the SendMessage API ' function to enter it in the Running Object Table. SendMessage hWnd, WM_USER + 18, 0, 0 End If End Function
Works great! Thank you!
"PC Datasheet" <sp**@nospam.sp am> schreef in bericht
news:p8******** **********@news read3.news.atl. earthlink.net.. . From my file:
See below my SIG
-- PC Datasheet Your Resource For Help With Access, Excel And Word Applications re******@pcdata sheet.com www.pcdatasheet.com
Refer To A Specific Cell In An Excel Worksheet ObjWkb.Workshee ts(1).Cells(Row , Col).Value
Row = Integer, specifying the row number
Col = Integer, specifying the column number
"Ronny Sigo" <ro********@sky net.be> wrote in message news:40******** *************** @feed0.news.be. easynet.net... Hello all, Could anybody help me referencing individual cells in excel? I don't
know what I do wrong here (but I'm not familiar with excel vba) (Microsoft
Excel 10.0 Object library is referenced) Any help very much appreciated Thanks Ronny
Private Sub btnTargetAffGro upEmailImport_C lick() Dim MyXL As Object Dim ExcelWasNotRunn ing As Boolean On Error Resume Next ' Defer error trapping. Set MyXL = GetObject(, "Excel.Applicat ion") If Err.Number <> 0 Then ExcelWasNotRunn ing = True Err.Clear DetectExcel ' I HAVE PASTED THIS FUNCTION BELOW ..... Set MyXL = GetObject("U:\M IJNTEST.XLS")
MyXL.Applicatio n.Visible = True MyXL.Parent.Win dows(1).Visible = True 'HERE I HAVE TO REFERENCE THE INDIVIDUAL CELLS MyXL.cell(2, 2) = "Een" MyXL.cell(2, 3) = "Twee" MyXL.cell(2, 4) = "Drie" MyXL.cell(2, 5) = "Vier"
If ExcelWasNotRunn ing = True Then MyXL.Applicatio n.Quit End If
Set MyXL = Nothing ' Release reference to the ' application and spreadsheet.
End Sub
Public Function DetectExcel() ' Procedure dectects a running Excel and registers it. Const WM_USER = 1024 Dim hWnd As Long ' If Excel is running this API call returns its handle. hWnd = FindWindow("XLM AIN", 0) If hWnd = 0 Then ' 0 means Excel not running. Exit Function Else ' Excel is running so use the SendMessage API ' function to enter it in the Running Object Table. SendMessage hWnd, WM_USER + 18, 0, 0 End If End Function
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: zxo102 |
last post by:
Hi there,
I need your help for python <--> excel. I want to paste selected
cells (range) to different location on the same sheet in Excel through
python. I have tried it for a while but could not figure it out. Here
is my sample code:
import win32com.client
xl=win32com.client.Dispatch("Excel.Application")
xl.Visible=1
wb = xl.Workbooks.Add( )
|
by: Ronny Sigo |
last post by:
Hello all,
Could anybody help me referencing individual cells in excel? I don't know
what I do wrong here (but I'm not familiar with excel vba) (Microsoft Excel
10.0 Object library is referenced)
Any help very much appreciated
Thanks
Ronny
Private Sub btnTargetAffGroupEmailImport_Click()
Dim MyXL As Object
|
by: Damian Arntzen |
last post by:
I'm a beginner to moderate programmer who's fiddling around with automating
Excel, in particular after being able to have the user fill out a form and it
then generate the workbook. I can't quite figure out how to get it to Merge
cells together - I've found how to do it (I think) but can't nut out the
syntax. Any help with this would be much appreciated (I've tried looking for
online tutorials, but the ones I've found never touch merging)....
|
by: Chris Bellini |
last post by:
Greetings! I'm developing a C# application that needs to read some data
from a selected XLS file. I've used VB in the past to automate Excel
but this is the first time I've used C#. Back in VB, I was able to
retrieve a cell's contents via something like this:
Set objExcellApp = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open(strPathToXLS)
' retrive the contents of A1
strData = objExcel.Cells(1, 1).Value
|
by: Lee |
last post by:
I am having a heck of a time trying to learn how to
manipulate Excel from Visual Basic.NET. Does anyone know
of any good reference articles or books that address this
subject specifically? I found one article on MSDN
called "Understanding the Excel Object Model from a .NET
Developer's Perspective" which is good but I need more
details such as how to open and existing spreadsheet,
copy data from one range of cells on one worksheet to a...
| |
by: Glen Vermeylen |
last post by:
Hi,
For a project at school we have to automate the assignment of seats in
classrooms to students during the exams.
The lady who previously did everything manually kept the layouts of the
classrooms in an excel-document: 1 sheet per classroom, and she marked
the cells which represent the seats with a border.
The problem however is that she sometimes merged cells together to get a
better layout.
|
by: mrid via DotNetMonster.com |
last post by:
hi. im exporting data from a vb form to excel. i am able to create a new
excel file, save and edit it without any trouble, but the formatting is
giving me hell! i need to be able to show certain cells in bold, with
underlining etc. i dont understand how, but in the following code, the
instruction for bold gets picked up for all the cells (even when i specify
font.bold = false), and the underlining is haphazardly used. the font colour...
|
by: thadson |
last post by:
Hi,
I'm trying to import specific cells from MS Excel 2000 spreadsheets to MS Access 2000 tables then move the spreadsheets to a different directory.
I'm very new to this and I'm having trouble to implement this.
I have worked out so far the code to import certain cells into 1 table, but I do not know how to import some other cells into another tables so the data would be connected and remain together.
So lets say that I have 2 tables...
|
by: ielamrani |
last post by:
Hi,
I am getting this error when I try to export to an excel sheet. When I click on a button to export the first time it's fine, I rename the exported excel sheet and I try to export it again and I get the error: Runtime Error 1004: Method ‘Cells’ of Object ‘_Global’ failed
It highlight this line:
Range("A1:L1").Select
sorry the code behind the button is long:
.
Dim stDocName As String
stDocName = "QFinal4"
|
by: randyse |
last post by:
Hello all,
This is my first post, please let me know if I've missed any relevant data or guidelines.
I'm using Access 2003 for the database and Excel 2003 for the reporting to avoid having everyone reading the reports install the snapshot viewer. I'm also porting this application to SQL Server/ASP.NET eventually, and there is not a way to install reporting services on the server, so my hope is to use Excel there as well.
I'm using two...
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |