Consulting

Page 2 of 2 FirstFirst 1 2
Results 21 to 28 of 28

Thread: TMP file not found error when creating multiple workbooks in a loop

  1. #21
    VBAX Regular
    Joined
    Mar 2018
    Posts
    15
    Location
    I have ran this on 2 other computers now and get mixed results. One does not error, the other errors some, but less than mine. I think this is some type of resource or priority issue. Can anyone help with this?

  2. #22
    Check your pc processes or schedule tasks for any scheduled temp cleaners.

  3. #23
    VBAX Regular
    Joined
    Mar 2018
    Posts
    15
    Location
    Temp files are cleared. I found this and it looks to be a similar problem that was called out as a bug:
    https://www.excelbanter.com/excel-di...vb***-tmp.html
    Since this is by no means a quick fix. Does anyone have another method to copy a sheet into a new workbook.
    BTW, did you try the sample loop and did it work for you?

  4. #24
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Does anyone have another method to copy a sheet into a new workbook.
    Sub SamT_TestLoopSample()
    Dim i As Long
    Dim NewBk As Object
    FPath = "Define" & PathSeparator
    
    Application.DisplayAlerts = False
    
    For i = 1 To 20
       FName = "Test" & i & ".xlsx"
    
       ThisWorkbook.Sheets("CopyMe").Move
       Set NewBk = ActiveWorkbook
       NewBk.SaveAs Filename:=FPath & FName
       NewBk.Close
    Next i
    
    Application.DisplayAlerts = True
    End Sub
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  5. #25
    VBAX Regular
    Joined
    Mar 2018
    Posts
    15
    Location
    Thank you SamT. The provided code doesn't copy the sheet, it moves it.

  6. #26
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Simply change ".Move" to ".Copy"
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  7. #27
    VBAX Regular
    Joined
    Mar 2018
    Posts
    15
    Location
    I have solved this by permanently moving the sheet I'm exporting into a template file, opening it, populating it, and saving it as the new file. This avoids the bug that I can't seem to get around. Thanks to all for the support.

  8. #28
    try running excel.exe as administrator. Right click -> run as administrator from the previous location.

Posting Permissions

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