+ Reply to Thread
Results 1 to 9 of 9

Run time error 70

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    12-12-2022
    Location
    italy
    MS-Off Ver
    office 365
    Posts
    164

    Run time error 70

    Hi everyone
    Can anyone explain to me why this macro, which worked perfectly on the home computer, tested on the company PC before, works and now doesn't work anymore?

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    mpath = ActiveWorkbook.Path
    mfile = "fis.csv"
    If Dir(mpath & "" & mfile) <> "" Then
    Kill mpath & "" & mfile
    Else
    MsgBox "File " & mfile & " non trovato"
    End If
    End Sub

    I highlight the part in yellow
    kill mpath & "" & mfile

    giving me as an error

    Run time error "70" Permission denied

    thanks a lot

  2. #2
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    3,046

    Re: Run time error 70

    You may need a \ between mpath and mfile since Activeworkbook.path doesn't end in one.
    If the workbook you're running this in isn't saved yet, then Activeworkbook.path will be blank.
    An error might be caused by mfile still being open or opened as read-only.

  3. #3
    Forum Contributor
    Join Date
    12-12-2022
    Location
    italy
    MS-Off Ver
    office 365
    Posts
    164

    Re: Run time error 70

    Hi, could you give me an example
    This is the code I use when opening and closing the file


    Private Sub Workbook_Open()


    strDir = "C:\Users\Cannonef\Desktop\OPS_Assegna Voli"
    With CreateObject("wscript.shell")

    .currentdirectory = strDir

    .Run "%comspec% /c ren *.xls FIS.csv", 0, True

    End With

    Application.Wait (Now + TimeValue("00:00:03"))
    ActiveWorkbook.RefreshAll


    End Sub


    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    mpath = ActiveWorkbook.Path
    mfile = "fis.csv"
    If Dir(mpath & "" & mfile) <> "" Then
    Kill mpath & "" & mfile
    Else
    MsgBox "File " & mfile & " non trovato"
    End If
    End Sub

  4. #4
    Forum Contributor
    Join Date
    12-12-2022
    Location
    italy
    MS-Off Ver
    office 365
    Posts
    164

    Re: Run time error 70

    Hi I tried like this but nothing always gives me the error

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    mpath = ActiveWorkbook.Path
    mfile = "fis.csv"
    If Dir(mpath & "" & mfile) <> "" Then
    Kill mpath & "" & mfile
    Else
    MsgBox "File " & mfile & " non trovato"
    End If
    End Sub

  5. #5
    Forum Contributor
    Join Date
    12-12-2022
    Location
    italy
    MS-Off Ver
    office 365
    Posts
    164

    Re: Run time error 70

    sorry it won't let me put the slash on the post

  6. #6
    Registered User
    Join Date
    09-01-2018
    Location
    USA
    MS-Off Ver
    365
    Posts
    96

    Re: Run time error 70

    just like it said in post#2
    mpath = ActiveWorkbook.Path
    mfile = "email.csv"
    If Dir(mpath & "\" & mfile) <> "" Then
    Kill mpath & "\" & mfile
    Else
    MsgBox "File " & mfile & " non trovato"
    End If

  7. #7
    Registered User
    Join Date
    07-27-2017
    Location
    italy
    MS-Off Ver
    2016
    Posts
    7

    Re: Run time error 70

    hi

    i think that cross-posting is not a good practice.

    I cannot show link because this is my 2nd / 3rd post, hope this is sufficient:

    www . forumexcel . it / forum / threads / errore-runtime-70.66907/


    best regards

  8. #8
    Forum Contributor
    Join Date
    12-12-2022
    Location
    italy
    MS-Off Ver
    office 365
    Posts
    164

    Re: Run time error 70

    I apologize to everyone, I didn't know that you couldn't post a request on different forums. I close the open discussion.
    sorry again

  9. #9
    Registered User
    Join Date
    07-27-2017
    Location
    italy
    MS-Off Ver
    2016
    Posts
    7

    Re: Run time error 70

    hi
    Are you not use to read rules??

    this is this Forum rule:
    3. Questions that are cross-posted to other web forums must contain links to those posts on those forums or a comment to tell us where else the question has been asked.
    And this ForumExcel rule (that you know very well):
    Regola nr. 3 "Crossposting" la stessa domanda vietata su più forum
    E' vietato postare lo stesso messaggio o parti di esso su altri forum, salvo casi di particolare interesse che dovranno comunque essere autorizzati da un Admin.
    It's not my habit to have this kind of behavior, but considering the time that was dedicated to you (over than 10 posts), you could have waited.....

    regards
    Last edited by doq7; 03-28-2023 at 01:35 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Error message: Run-Time error '1004 '; application-defined or object-defined error
    By Davasu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2015, 06:52 AM
  2. Replies: 1
    Last Post: 10-22-2015, 05:50 AM
  3. VBA ERROR: run time error 1004: Application-defined or Object-defined error in excel 2013
    By AnanthKrishna in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-13-2015, 06:16 AM
  4. Cannot Publish Excel Pivot Chart - Run Time Error
    By crisb184 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-11-2013, 07:04 AM
  5. [SOLVED] Error " Run-time error '1004': application defined or object defined error
    By lengwer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-11-2013, 07:26 AM
  6. run-time error ;2147023179 (800706b5) time automation error interface unknown
    By karthik72 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-02-2012, 09:31 AM
  7. Error "run-time Error '1004': General Odbc Error
    By D4WNO77 in forum Access Tables & Databases
    Replies: 2
    Last Post: 07-16-2012, 09:55 AM

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