+ Reply to Thread
Results 1 to 3 of 3

Stop "Save as" and Copy File

  1. #1
    maperalia
    Guest

    Stop "Save as" and Copy File

    Could you help me to refine this program?

    I have this statement (see below) that sends a message when the file was
    saved already. However, when I click OK the program saves as a copy of
    the file instead of just STOP.
    Basically, I do not want the program to save as a copy. I just want to stop
    as soon as I click OK

    Thanks in advance for your help.
    Maperalia

    ************************************
    If ThisWorkbook.Saved = False Then
    MsgBox "File Has Been Saved Already"
    Exit Sub
    End If

    ActiveWorkbook.SaveCopyAs Progname

    ************************************


  2. #2
    Vasant Nanavati
    Guest

    Re: Stop "Save as" and Copy File

    Change the first line to:

    If ActiveWorkbook.Saved Then

    --

    Vasant


    "maperalia" <[email protected]> wrote in message
    news:[email protected]...
    > Could you help me to refine this program?
    >
    > I have this statement (see below) that sends a message when the "file was
    > saved already". However, when I click "OK" the program "saves as" a copy
    > of
    > the file instead of just STOP.
    > Basically, I do not want the program to save as a copy. I just want to
    > stop
    > as soon as I click "OK"
    >
    > Thanks in advance for your help.
    > Maperalia
    >
    > '************************************
    > If ThisWorkbook.Saved = False Then
    > MsgBox "File Has Been Saved Already"
    > Exit Sub
    > End If
    >
    > ActiveWorkbook.SaveCopyAs Progname
    >
    > '************************************
    >




  3. #3
    maperalia
    Guest

    Re: Stop "Save as" and Copy File

    Vasant;
    Thanks for your quick response. I used the statement you advised me but I
    got the following window message:

    Run-time error ‘1004’
    Cannot access read-only document ‘filename.xls’

    Then after I click debug it is highlighting in the following statement:

    ActiveWorkbook.SaveCopyAs Progname

    Could you please tell me how to fix it?.. I would like to have the message
    “The File Has Been Saved Already” after I hit the button’s macro for second
    time. So I will know that I have to change the filename I order to save it.

    See program below for reference

    Regards.
    Maperalia

    ‘*****Start of Program**************
    Sub SaveExcelFile()
    Dim boError As Boolean
    Dim strError As String
    Dim Tract As String
    Dim WO As String
    Dim Supplier As String
    Dim Dates As String
    Dim Time As String
    Dim sFilename As String
    Dim Progname As String
    Dim Filename As String
    '***************************************************************
    'Setup File Name
    strError = ""
    boError = False
    With Worksheets("Gradation Form")
    If .Range("G2") = "" Then
    boError = True
    strError = strError & "WORK ORDER # "
    End If
    If .Range("G3") = "" Then
    boError = True
    strError = strError & "TRACT #"
    End If
    If .Range("C6") = "" Then
    boError = True
    strError = strError & "SUPPLIER "
    End If
    If .Range("G4") = "" Then
    boError = True
    strError = strError & "DATE "
    End If
    If .Range("G5") = "" Then
    boError = True
    strError = strError & "TIME"
    End If
    If boError = True Then
    MsgBox "The Following Ranges have not been Typed Yet - " & strError
    Exit Sub
    Else
    WO = Worksheets("Gradation Form").Range("G2")
    Tract = Worksheets("Gradation Form").Range("G3")
    Supplier = Worksheets("Gradation Form").Range("C6")
    Dates = Worksheets("Gradation Form").Range("G4")
    Time = Worksheets("Gradation Form").Range("G5")
    Filename = "" & WO & "_" & Tract & "_" & Supplier & "_" & Dates &
    "_" & Time & ""
    Progname = "C:\Mario\Macro Samples\Excel\Gradation\Gradation Form
    Rev1\" & Filename & ".xls"

    If ActiveWorkbook.Saved Then
    MsgBox "File Has Been Saved Already"
    Exit Sub
    End If


    ActiveWorkbook.SaveCopyAs Progname



    Call ListOfFileSave(Filename)


    End If
    End With
    End Sub

    ‘*****End of Program**************


    "Vasant Nanavati" wrote:

    > Change the first line to:
    >
    > If ActiveWorkbook.Saved Then
    >
    > --
    >
    > Vasant
    >
    >
    > "maperalia" <[email protected]> wrote in message
    > news:[email protected]...
    > > Could you help me to refine this program?
    > >
    > > I have this statement (see below) that sends a message when the "file was
    > > saved already". However, when I click "OK" the program "saves as" a copy
    > > of
    > > the file instead of just STOP.
    > > Basically, I do not want the program to save as a copy. I just want to
    > > stop
    > > as soon as I click "OK"
    > >
    > > Thanks in advance for your help.
    > > Maperalia
    > >
    > > '************************************
    > > If ThisWorkbook.Saved = False Then
    > > MsgBox "File Has Been Saved Already"
    > > Exit Sub
    > > End If
    > >
    > > ActiveWorkbook.SaveCopyAs Progname
    > >
    > > '************************************
    > >

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1