|
-
Feb 15th, 2001, 11:27 AM
#1
Thread Starter
Hyperactive Member
I am trying to open an existing spreadsheet and add a few extra lines then close the spreadsheet.
Private Sub Command3_Click()
Dim spreadsheetname As String
Dim objXLS As New Excel.Application
spreadsheetname = "c:\vbstuff\book3.xls"
With objXLS
.Workbooks.Open spreadsheetname
Rows("1:1").Select
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Range("F1").Select
ActiveCell.FormulaR1C1 = "xxx"
Range("F2").Select
ActiveCell.FormulaR1C1 = "xxx"
Range("F3").Select
ActiveCell.FormulaR1C1 = "xxx"
Range("F4").Select
ActiveCell.FormulaR1C1 = "xxx"
Range("F7").Select
End With
Set objXLS = Nothing
MsgBox "finito"
End Sub
I want to look and see if it has done as I asked. But when I open the excel ss I get this message.
"book3.xls is already open , reopening it will discard any changes do you want to reopen "
I dont think I am releasing the spreadsheet again in my code , how do I do this ? . I want the code to run, add the extra data to the ss then when the code is finnished I wish to then open excel , open my workbook and see the changes without any hassle
cheers
-
Feb 15th, 2001, 11:38 AM
#2
Hyperactive Member
I see you called workbook.Open.
Is there a similar command to close the workbook...say:
workbook.close
or something to that nature. That seems to be the only problem with the code you have posted.
hope it helps.
"If I had known it was going to be that kinda party, I would have stuck my disk in the mash potatos!"
-
Feb 15th, 2001, 11:45 AM
#3
Frenzied Member
You need to save it then quit.
.saveas "path\filename"
.application.quit
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

-
Feb 15th, 2001, 11:46 AM
#4
Thread Starter
Hyperactive Member
thanks
thanks dude , that was it , it always helps to have another pair of fresh eyes looking at your code.
thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|