ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   More help on closing Excel.Application (https://www.excelbanter.com/excel-programming/286271-more-help-closing-excel-application.html)

Snedker[_2_]

More help on closing Excel.Application
 
Okay - it seems I haven't explained myself properly, so:

Would someone show me a VBA example of:

1.
Open "C:\mywork.xls" using the Excel.Appliction object

2.
Enter "Hello World" into cell A1

3.
Releasing connections to the open xls-file, but leaving it open for
further work.

4.
The code should be able to be re-run an infinite number of times, each
time opening "C:\mywork.xls" in a new instance of Excel.


Help greatly appreciated! Thx in advance.

/Snedker

Rob van Gelder[_4_]

More help on closing Excel.Application
 
Sub testit()
Dim app As Application, wkb As Workbook, i As Long

For i = 1 To 3
Set app = New Application
app.Visible = True
Set wkb = app.Workbooks.Open("C:\mywork.xls")
wkb.Worksheets(1).Cells(1, 1) = "Hello World"
Set wkb = Nothing
Set app = Nothing
Next
End Sub

Keep in mind that the second time you open mywork.xls it will be read-only
(unless it's a shared workbook)


"Snedker" wrote in message
...
Okay - it seems I haven't explained myself properly, so:

Would someone show me a VBA example of:

1.
Open "C:\mywork.xls" using the Excel.Appliction object

2.
Enter "Hello World" into cell A1

3.
Releasing connections to the open xls-file, but leaving it open for
further work.

4.
The code should be able to be re-run an infinite number of times, each
time opening "C:\mywork.xls" in a new instance of Excel.


Help greatly appreciated! Thx in advance.

/Snedker




Henry[_5_]

More help on closing Excel.Application
 
Snedker,

How much memory has your system got?
It must be infinite, if you're hoping to open an infinite number of
instances of Excel!!

HTH
Henry


"Snedker" wrote in message
...
Okay - it seems I haven't explained myself properly, so:

Would someone show me a VBA example of:

1.
Open "C:\mywork.xls" using the Excel.Appliction object

2.
Enter "Hello World" into cell A1

3.
Releasing connections to the open xls-file, but leaving it open for
further work.

4.
The code should be able to be re-run an infinite number of times, each
time opening "C:\mywork.xls" in a new instance of Excel.


Help greatly appreciated! Thx in advance.

/Snedker




Snedker[_2_]

More help on closing Excel.Application
 
On Fri, 26 Dec 2003 22:07:35 -0000, "Henry"
wrote:

Well, you shouldn't take it literally :-)

My VB-app will open the workbook and enter data automatically. They
should be able to return to the VB-app push a button and a new
instance of the workbook will be opened.

The workbook is initially read-only, so they're supposed to save to a
new filename anyway.

"Several times" would be a more appropiate choice of words, rather
than "infinite".

Regards
/Snedker

Snedker,

How much memory has your system got?
It must be infinite, if you're hoping to open an infinite number of
instances of Excel!!

HTH
Henry




Tushar Mehta

More help on closing Excel.Application
 
You may want to check

Office Application Automation
http://msdn.microsoft.com/library/de...l=/library/en-
us/modcore/html/deconAutomatingOtherOfficeApplications.asp

and

Creation of Object Variables to Automate Another Office Application
http://msdn.microsoft.com/library/de...l=/library/en-
us/modcore/html/deconCreatingObjectVariableToAutomateAnotherOffice Appli
cation.asp

While there check out other related topics shown in the left hand
navigation bar.

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article , morten@
[nospam_]dbconsult.dk says...
Okay - it seems I haven't explained myself properly, so:

Would someone show me a VBA example of:

1.
Open "C:\mywork.xls" using the Excel.Appliction object

2.
Enter "Hello World" into cell A1

3.
Releasing connections to the open xls-file, but leaving it open for
further work.

4.
The code should be able to be re-run an infinite number of times, each
time opening "C:\mywork.xls" in a new instance of Excel.


Help greatly appreciated! Thx in advance.

/Snedker



All times are GMT +1. The time now is 10:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com