+ Reply to Thread
Results 1 to 3 of 3

Kill

Hybrid View

Guest Kill 08-23-2005, 06:05 AM
Guest Re: Kill 08-23-2005, 06:05 AM
Guest Re: Kill 08-23-2005, 07:05 AM
  1. #1
    Michael
    Guest

    Kill

    Hi again..

    I need more help. Sorry!

    When the workbook is opened ( 1 sheet called VT) its saved back to the
    original location with a new report number, and then saved to a temp folder
    where it is while the user work on it. After the user is finished the sheet
    is duplicated to a new workbook in a new location.

    Everything is ok with that, but then i want to delete the workbook that is
    in the temp folder by the macro in that workbook.

    The temp location is:

    FileSaveName = ActiveWorkbook.Path
    FileSaveNameEnd = FileSaveName & "\Arkiv\"
    varName = ActiveSheet.Name
    varDir = FileSaveNameEnd
    varYear = Format(Date, "yyyy")
    varNr = ReportNumber

    On Error GoTo xlErrorHandler:

    ActiveSheet.SaveAs Filename:=varDir & varName & varNr & varYear

    at the end of the sub i have this code:

    Kill "varDir & varName & varNr & varYear"

    End Sub

    Is it possible to "kill" the workbook while its still running or should i
    "kill" it from another location (program)?

    Michael
    --
    Nil Satis Nisi Optimum

  2. #2
    Bob Phillips
    Guest

    Re: Kill

    Hi Michael,

    Try this

    Sub Michael()
    FileSaveName = ActiveWorkbook.Path
    FileSaveNameEnd = FileSaveName & "\Arkiv\"
    varName = ActiveSheet.Name
    varDir = FileSaveNameEnd
    varYear = Format(Date, "yyyy")
    varNr = ReportNumber

    ActiveSheet.SaveAs Filename:=varDir & varName & varNr & varYear

    With ActiveWorkbook
    If .Path <> "" Then
    .Saved = True
    .ChangeFileAccess xlReadOnly
    Kill ActiveWorkbook.FullName
    End If
    End With

    End Sub


    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Michael" <Michael@discussions.microsoft.com> wrote in message
    news:283265A0-2491-49DE-A01D-E8A5775F4D61@microsoft.com...
    > Hi again..
    >
    > I need more help. Sorry!
    >
    > When the workbook is opened ( 1 sheet called VT) its saved back to the
    > original location with a new report number, and then saved to a temp

    folder
    > where it is while the user work on it. After the user is finished the

    sheet
    > is duplicated to a new workbook in a new location.
    >
    > Everything is ok with that, but then i want to delete the workbook that is
    > in the temp folder by the macro in that workbook.
    >
    > The temp location is:
    >
    > FileSaveName = ActiveWorkbook.Path
    > FileSaveNameEnd = FileSaveName & "\Arkiv\"
    > varName = ActiveSheet.Name
    > varDir = FileSaveNameEnd
    > varYear = Format(Date, "yyyy")
    > varNr = ReportNumber
    >
    > On Error GoTo xlErrorHandler:
    >
    > ActiveSheet.SaveAs Filename:=varDir & varName & varNr & varYear
    >
    > at the end of the sub i have this code:
    >
    > Kill "varDir & varName & varNr & varYear"
    >
    > End Sub
    >
    > Is it possible to "kill" the workbook while its still running or should i
    > "kill" it from another location (program)?
    >
    > Michael
    > --
    > Nil Satis Nisi Optimum




  3. #3
    Michael
    Guest

    Re: Kill

    Hi Bob.

    Thank's again. You helped me a lot, again:-)

    It works just like i hoped, nice.

    Michael
    --
    Nil Satis Nisi Optimum


    "Bob Phillips" wrote:

    > Hi Michael,
    >
    > Try this
    >
    > Sub Michael()
    > FileSaveName = ActiveWorkbook.Path
    > FileSaveNameEnd = FileSaveName & "\Arkiv\"
    > varName = ActiveSheet.Name
    > varDir = FileSaveNameEnd
    > varYear = Format(Date, "yyyy")
    > varNr = ReportNumber
    >
    > ActiveSheet.SaveAs Filename:=varDir & varName & varNr & varYear
    >
    > With ActiveWorkbook
    > If .Path <> "" Then
    > .Saved = True
    > .ChangeFileAccess xlReadOnly
    > Kill ActiveWorkbook.FullName
    > End If
    > End With
    >
    > End Sub
    >
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "Michael" <Michael@discussions.microsoft.com> wrote in message
    > news:283265A0-2491-49DE-A01D-E8A5775F4D61@microsoft.com...
    > > Hi again..
    > >
    > > I need more help. Sorry!
    > >
    > > When the workbook is opened ( 1 sheet called VT) its saved back to the
    > > original location with a new report number, and then saved to a temp

    > folder
    > > where it is while the user work on it. After the user is finished the

    > sheet
    > > is duplicated to a new workbook in a new location.
    > >
    > > Everything is ok with that, but then i want to delete the workbook that is
    > > in the temp folder by the macro in that workbook.
    > >
    > > The temp location is:
    > >
    > > FileSaveName = ActiveWorkbook.Path
    > > FileSaveNameEnd = FileSaveName & "\Arkiv\"
    > > varName = ActiveSheet.Name
    > > varDir = FileSaveNameEnd
    > > varYear = Format(Date, "yyyy")
    > > varNr = ReportNumber
    > >
    > > On Error GoTo xlErrorHandler:
    > >
    > > ActiveSheet.SaveAs Filename:=varDir & varName & varNr & varYear
    > >
    > > at the end of the sub i have this code:
    > >
    > > Kill "varDir & varName & varNr & varYear"
    > >
    > > End Sub
    > >
    > > Is it possible to "kill" the workbook while its still running or should i
    > > "kill" it from another location (program)?
    > >
    > > Michael
    > > --
    > > Nil Satis Nisi Optimum

    >
    >
    >


+ 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