473,409 Members | 2,004 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,409 software developers and data experts.

Excel already runnig, how to update with VB

I would like to be able to use VB 2003 .NET to check if Excel is
running, and if it is, then do something with the active workbook.

I can see if Excel is running:

Private Sub GetAllExcelApps()

Dim AllExeclProcesses() As Process
Dim OneExcelProcess As Process
Dim OneExcelApp As Excel.Application

' get all open instances of excel
AllExeclProcesses = Process.GetProcessesByName("EXCEL")

' Iterate through the process array.
For Each OneExcelProcess In AllExeclProcesses
' do something
Next
End Sub

But how do I convert OneExcelProcess into OneExcelApp? I can create an
Excel Application instance:

Private Sub MyExcelProcess()
Dim MyExcelApp As Excel.Application = New Excel.Application

' do somthing

MyExcelApp.Quit()
MyExcelApp = Nothing
End Sub

But I do not want a new Excel application. I want to be able to do
something only is Excel is already running.

Thanks

Aug 3 '06 #1
2 1202
I'm not sure if it will work, but maybe try using a direct cast statement or
something similar:

Dim OneExcelApp as Excel.Application
OneExcelApp = DirectCast(OneExcelProcess, Excel.Application)

"ea********@gmail.com" wrote:
I would like to be able to use VB 2003 .NET to check if Excel is
running, and if it is, then do something with the active workbook.

I can see if Excel is running:

Private Sub GetAllExcelApps()

Dim AllExeclProcesses() As Process
Dim OneExcelProcess As Process
Dim OneExcelApp As Excel.Application

' get all open instances of excel
AllExeclProcesses = Process.GetProcessesByName("EXCEL")

' Iterate through the process array.
For Each OneExcelProcess In AllExeclProcesses
' do something
Next
End Sub

But how do I convert OneExcelProcess into OneExcelApp? I can create an
Excel Application instance:

Private Sub MyExcelProcess()
Dim MyExcelApp As Excel.Application = New Excel.Application

' do somthing

MyExcelApp.Quit()
MyExcelApp = Nothing
End Sub

But I do not want a new Excel application. I want to be able to do
something only is Excel is already running.

Thanks

Aug 3 '06 #2
Okay I tried DirectCast and it didn't work. I also tried CType and that
didn't work either.

If you absolutley have to perform something with the Excel file that is
already open, maybe you should use VBA?

A temporary workaround might be to terminate the running Excel process and
then force the user to reselect the file in an OpenFileDialog and then create
a new instance of the workbook that way. Although that is rather lame.
"John" wrote:
I'm not sure if it will work, but maybe try using a direct cast statement or
something similar:

Dim OneExcelApp as Excel.Application
OneExcelApp = DirectCast(OneExcelProcess, Excel.Application)

"ea********@gmail.com" wrote:
I would like to be able to use VB 2003 .NET to check if Excel is
running, and if it is, then do something with the active workbook.

I can see if Excel is running:

Private Sub GetAllExcelApps()

Dim AllExeclProcesses() As Process
Dim OneExcelProcess As Process
Dim OneExcelApp As Excel.Application

' get all open instances of excel
AllExeclProcesses = Process.GetProcessesByName("EXCEL")

' Iterate through the process array.
For Each OneExcelProcess In AllExeclProcesses
' do something
Next
End Sub

But how do I convert OneExcelProcess into OneExcelApp? I can create an
Excel Application instance:

Private Sub MyExcelProcess()
Dim MyExcelApp As Excel.Application = New Excel.Application

' do somthing

MyExcelApp.Quit()
MyExcelApp = Nothing
End Sub

But I do not want a new Excel application. I want to be able to do
something only is Excel is already running.

Thanks
Aug 3 '06 #3

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

Similar topics

3
by: Chris | last post by:
Could someone please provide me an effective means of exporting data from a data set (or data grid) to Excel?
12
by: jimserac | last post by:
I had previously posted this in an Access forum with negative results so will try here. Although this question specifies an Access database, I also wish to accomplish this with a large MS SQL...
1
by: jimserac | last post by:
The following SQL statement, used in VBScript, will COPY a table from Excel to an Access mdb. SQL = "SELECT * INTO C1R0" & _ " FROM IN ''" & _ " 'Excel...
1
by: Jason Huang | last post by:
Hi, My C# Windows Form application has a form frmExcel which will write data to an Excel 2000 file MyExcel.xls. But if the application is still runnig then the MyExcel.xls can not be opened...
1
by: Patonar | last post by:
Hi, I would like to be able to using VBA from an Excel macro - go through each line in my spreadsheet and add to a database. I know that this can be done via the import external data tool in...
0
by: NiteshR | last post by:
Hi, I am developing an application that is required to update excel spreadsheets which currently take over to update. I need to create an application using C# and it needs to call the function...
1
by: BLavanya | last post by:
I want to Open an excel sheet , then I want to loop through the rows in the excel sheet and should execute an update query for all the rows where the where condition in the query should match the...
5
by: tsanthoshk | last post by:
Hi All I am trying to read and modify input excel file. when i update the data in excel sheet already existing format is washing out. It mean if excel sheet contain colors those are not appearing...
15
by: OfficeDummy | last post by:
Hello all! I searched the Internet and this forum for a similar problem, but I found no help... Also, I'm a complete newbie to the fascinating world of programming, VBA and Access, so my question...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...
0
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,...
0
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...
0
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...

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.