Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jul 2001
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Kill Statement (acc 97)

    Hi i am trying to use the Kill command to delete an xls file when I run the following code from access.

    Public Function blnDumMAP() As Boolean

    Dim appExcel As Excel.Application

    ' Link to Excel using automation
    Set appExcel = CreateObject("Excel.Application")

    ' So you can watch what's happening...
    appExcel.Visible = False

    ' Open Dummy File
    appExcel.Workbooks.Open "CatabaseDummy.xls"

    appExcel.Visible = True
    ' Open Management Action Plan
    appExcel.Workbooks.Open "CatabaseManagement Action Plan.xls"


    ' Calculate ('read' values from dummy file
    appExcel.Calculate


    'Close the dummy workbook (without saving changes)
    appExcel.Workbooks("Dummy.xls").Close False

    Kill ("CatabaseDummy.xls") ' PROBLEM HERE

    End Function


    However, i always get a 'file not found error' I even tried to enter the code as a macro in excel and then run that macro from access but the comp still cant find the file. Yes it is typed correctly. I've checked a milllion times. AM i missing something?

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Kill Statement (acc 97)

    you use
    appExcel.Workbooks("Dummy.xls").Close False

    The false argument say to not save the workbook.
    If it is not saved, it can't be deleted
    Francois

  3. #3
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Kill Statement (acc 97)

    Hi,
    Try removing the parentheses around the file name and see if that helps - i.e. Kill "CatabaseDummy.xls"
    Regards,
    Rory

    Microsoft MVP - Excel

Posting Permissions

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