Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting the name if a saved file in Excel.

Status
Not open for further replies.

FreedomP

ISP
Jun 28, 2003
14
CA
I am trying to data in an excel file to store it. I am able to save a file but I cannot set the actual files name.

Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
Dim path As String
'Start a new workbook in Excel
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add


'Add data to cells of the first worksheet in the new workbook
Set oSheet = oBook.Worksheets(1)
oSheet.Range("A1").Value = First
oSheet.Range("A2").Value = Last
oSheet.Range("A3").Value = Gender
oSheet.Range("A4").Value = Age
oSheet.Range("A5").Value = Weight
oSheet.Range("A6").Value = Feet
oSheet.Range("A7").Value = Inches
oSheet.Range("A8").Value = User
oSheet.Range("A9").Value = Password
oSheet.Range("A10").Value = Question
oSheet.Range("A11").Value = Answer
path = "C:\MyFiles\Visual Basic 6.0\Excel Storage\" + User
'Save the Workbook and Quit Excel
oBook.SaveAs path
oExcel.Quit
 
Well nevermind, I just forgot to source my variables from their form.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top