CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Location
    Fort Worth Texas
    Posts
    614

    Saving an Excel Sheet

    I am making use of Excel's automation and I use the Excel worksheet method of SaveAs. If the path and name of the file already exists I get the option to either overwrite the existing file, not overwrite, ot cancel. What I need is a way to have the option that if there is an existing file, then be able to input a new name, is there a Excel method that does that?


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Saving an Excel Sheet

    since you use automation (probably from VB), you can use VB to check for the existence of the file as in

    Dim strfile as string
    strfile = "c:\x.xls"
    If Dir(strfile) <> "" then
    x.Visible = true
    x.WindowState = xlNormal
    strfile = x.GetSaveAsFilename(strfile)
    End If
    x.ActiveWorkbook.SaveAs FileName:=strfile, ConflictResolution:=xlUserResolution





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

Featured