Saving Excel file after creating it...
I've created an excel file. It works fine. Opens up fine.
Now I want to save this file.
Here's my current code.
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim excel As New Excel.Application
excel.Workbooks.Add()
excel.Range("b1:c1").Select()
excel.Selection.Font.Bold = True
excel.Range("b1").Select()
excel.ActiveCell.Value = "Questions"
excel.Range("c1").Select()
excel.ActiveCell.Value = "Answers"
excel.Visible = True
Now, I want to save the file (either before or after it is displayed to the user)
I was looking for a excel.saveFile function but can't find it. ;)
How would I save this?
something like excel.save(application.startuppath & myvar & ".xls")
Thanks...
Re: Saving Excel file after creating it...
Its under the Workbooks collection.
VB Code:
Dim oWB as excel.workbook
'...
'...
oWB = excel.Workbooks.Add()
'...
'...
oWB.SaveAs FileName:="C:\Test.xls"
oWB.Saved = True
oWB.Close
'...
You should always use the workbook set to an object variable when working with workbooks. ;)
Ps, Gangsta Yoda says: Use the Force Darth. I am your Dad! :lol:
Re: Saving Excel file after creating it...
That was it. Thanks!
btw, you may know the power of VB.net. But you do NOT know the power of the Dark Side! :bigyello:
Re: Saving Excel file after creating it...
No, you dont know the power of the Jedi as I had to school you on how to do this. :D ;)
I see you changed your avatar. :thumb: Now we can battle it out via coding. :lol: