Using VB to manipulate Excel

I asked a question a while back, and I know how to add values to cells, etc, but I want to know the following:

1) How do I copy a sheet and rename it using VB?

2) How can I save under a different filename?

3) How can I do a Application.Quit without having it ask me if I want to save my changes?

Basically I have a workbook with a template framework, I want a VB 6.0 app to fill in values, the 'save as' it to a different name.

Who is Participating?
2) Just a syntax correction (as Chrynoble is brain dead ;-)):

xlapp.ActiveWorksheet.SaveAs "C:\Whatever"

(no space between "Save" & "As")

3) A better way to disable the 'Save Changes?" dialog is to set the Saved property of all open workbooks to Yes.
xlapp.DisplayAlerts = False will remain that way the next time you (or someone else who would like to see that alert) opens Excel.
In that cas, put this before the xlapp.Quit line:

For Each wb in xlapp.Workbooks
Next wb

If you only have the single workbook opened:

xlapp.ActiveWorkbook.Saved = True

Good Luck

This answer assumes you know how to create an excel object.

 xlapp.worksheets(yoursheet).copy Before:=Sheets(thesheet)
' You can also use the keyword after here

2) as "C:\Whatever"

 xlapp.displayalerts = false
 ' Add the above line before quiting.
Sorry forgot one
1) = "thename"
 ' You may also what to use "thename.xls"
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Sorry, I am brain dead today. You only want to use "thename.xls" if you are renaming the workbook, not the sheet.
Here is what i tried.

say you already have values in your worksheet. Then you want to copy these values into another sheet, it will create another sheet for you.

so what you do is this.
'xlSheet is Excel.WorkSheet
'xlBook is Excel.WorkBook
when using Copy Method you have there 2 parameters you might want to use them.If you want to copy certain rows only. This will copy an entire WorkSheet.

xlSheet.SaveAs FileName:="YourFile.xls"
xlBook.Close SaveChanges:=False
edskeeAuthor Commented:
Awesome, just about all I was looking for. Can you reccomend a website that has this info? Every time I try to do something new I gotta ask another question on here :)

I don't know or use any websites for this kind of stuff. Just practice, and participation on this site (try to comment on questions too, specificically in the MSOffice section if you'll need to work with Excel a lot).

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.