Results 1 to 5 of 5

Thread: [RESOLVED] Excel Save Help?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    31

    Resolved [RESOLVED] Excel Save Help?

    Can anyone help by telling me what is wrong with my code. I am trying to automate saving an excel file once data has been input. The problem is I still get a command asking if I wish to save changes to the file that already exists even although i've just saved it as this filename!

    strPath = "C:\Test\"
    strFile = frmStartScreen.Text1.Text & ".xls"
    strFileName = strPath & strFile

    On Error Resume Next
    Set objExcel = GetObject(, "Excel.Application")
    On Error GoTo ErrRoutine
    If objExcel Is Nothing Then
    Set objExcel = New Excel.Application
    End If

    If Text1.Text = "1" Then
    With objExcel
    .Workbooks.Open "C:\Test\Test.xls"
    .Cells(1, 1) = Text3.Text
    .Cells(2, 1) = Text2.Text
    .Cells(3, 1) = Text4.Text
    .Cells(4, 1) = Text5.Text
    .Cells(5, 1) = Text6.Text
    .Cells(6, 1) = Text7.Text
    .Cells(7, 1) = Text8.Text
    .Cells(8, 1) = Text9.Text
    .ActiveWorkbook.SaveAs strFileName
    .ActiveWorkbook.Close savechanges:=True
    End With
    End If

  2. #2
    Lively Member
    Join Date
    Apr 2005
    Posts
    103

    Re: Excel Save Help?

    Do you have to use double-backslashes for the path, maybe?

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    31

    Re: Excel Save Help?

    Not sure what you mean? Do you mean typing

    strPath = "C:\\Test\\" 'or something?

  4. #4
    Lively Member
    Join Date
    Apr 2005
    Posts
    103

    Re: Excel Save Help?

    Yeah, it's just a guess though.
    I'm not sure why you need to specify savechanges as True, seeing as you've already saved the file in the previous line.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    31

    Re: Excel Save Help?

    That appears to have worked. Thanks a lot!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width