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
Dim ExcelWasNotRunning As Boolean
On Error Resume Next ' Defer error trapping.
Set MyXL = GetObject(, "Excel.Application")
If Err.Number <> 0 Then ExcelWasNotRunning = True
Err.Clear
DetectExcel ' I HAVE PASTED THIS FUNCTION BELOW .....
Set MyXL = GetObject("U:\MIJNTEST.XLS")
MyXL.Application.Visible = True
MyXL.Parent.Windows(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 ExcelWasNotRunning = True Then
MyXL.Application.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("XLMAIN", 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 3279
From my file:
See below my SIG
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications re******@pcdatasheet.com www.pcdatasheet.com
Refer To A Specific Cell In An Excel Worksheet
ObjWkb.Worksheets(1).Cells(Row, Col).Value
Row = Integer, specifying the row number
Col = Integer, specifying the column number
"Ronny Sigo" <ro********@skynet.be> wrote in message
news:40***********************@feed0.news.be.easyn et.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 btnTargetAffGroupEmailImport_Click() Dim MyXL As Object Dim ExcelWasNotRunning As Boolean On Error Resume Next ' Defer error trapping. Set MyXL = GetObject(, "Excel.Application") If Err.Number <> 0 Then ExcelWasNotRunning = True Err.Clear DetectExcel ' I HAVE PASTED THIS FUNCTION BELOW ..... Set MyXL = GetObject("U:\MIJNTEST.XLS")
MyXL.Application.Visible = True MyXL.Parent.Windows(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 ExcelWasNotRunning = True Then MyXL.Application.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("XLMAIN", 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.spam> schreef in bericht
news:p8******************@newsread3.news.atl.earth link.net... From my file:
See below my SIG
-- PC Datasheet Your Resource For Help With Access, Excel And Word Applications re******@pcdatasheet.com www.pcdatasheet.com
Refer To A Specific Cell In An Excel Worksheet ObjWkb.Worksheets(1).Cells(Row, Col).Value
Row = Integer, specifying the row number
Col = Integer, specifying the column number
"Ronny Sigo" <ro********@skynet.be> wrote in message news:40***********************@feed0.news.be.easyn et.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 btnTargetAffGroupEmailImport_Click() Dim MyXL As Object Dim ExcelWasNotRunning As Boolean On Error Resume Next ' Defer error trapping. Set MyXL = GetObject(, "Excel.Application") If Err.Number <> 0 Then ExcelWasNotRunning = True Err.Clear DetectExcel ' I HAVE PASTED THIS FUNCTION BELOW ..... Set MyXL = GetObject("U:\MIJNTEST.XLS")
MyXL.Application.Visible = True MyXL.Parent.Windows(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 ExcelWasNotRunning = True Then MyXL.Application.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("XLMAIN", 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...
|
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)...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |