Can't get folder to create on desktop. When debugging it shows no errors.

dallas2024

New Member
Joined
Oct 25, 2024
Messages
14
Office Version
  1. 365
Platform
  1. Windows
VBA Code:
Sub WO_SaveUpdate()
Dim WORow As Long, WOCol As Long
Dim AssignedTo As String, SharedFolder As String, FileName As String, FilePath As String

ActiveWorkbook.Save
   
   Application.ScreenUpdating = False
   
With Sheet1
 If .Range("D4").Value = Empty Or .Range("H4").Value = Empty Or .Range("D10").Value = Empty Or .Range("C15").Value = Empty Then
    MsgBox "Please Complete Yellow Boxes"
    Exit Sub
 End If
 End With


With Sheet3
If .Range("C4").Value = Empty Then
    MsgBox "Please add in a shared folder location"
    Exit Sub
End If
End With

With Sheet2
If Worksheets("WO Data").Range("B11").Value = True Then 'new WOrk order
    WORow = .Range("C99999").End(xlUp).Row + 1  'First Avail. Row
Else ' Existing Work Order
End If
End With


With Sheet1
 For WOCol = 3 To 11
   Sheet2.Cells(WORow, WOCol).Value = .Range(.Cells(30, WOCol).Value).Value 'Place values in WO Row
    Sheet4.Range(.Cells(29, WOCol).Value).Value = .Range(.Cells(30, WOCol).Value).Value 'Place Values in WO Template
 Next WOCol
 Sheet2.Range("B11").Value = False 'Set new WO to false
Sheet2.Range("B12").Value = WORow


'Create/Update Work Order in Shared folder if status is Open
If .Range("D8").Value = "Open" Then
    AssignedTo = .Range("H4").Value 'Assigned To
    SharedFolder = Sheet3.Range("C4").Value 'Shared Folder location
    FileName = "Work Order_" & .Range("D6").Value 'File Name Work Order & #
    If Dir(SharedFolder & "\" & AssignedTo, vbDirectory) = "" Then MkDir (SharedFolder & "\" & AssignedTo) 'Create Folder if it does not exist
    FilePath = SharedFolder & "\" & AssignedTo & "\" & FileName & ".xlsx"
    On Error Resume Next
    Kill (FilePath)
    On Error GoTo 0
    Sheet4.Range("A1:B26").Copy
    Workbooks.Add
    ActiveWorkbook.Sheets(1).Range("A1").PasteSpecial xlPasteAll
    ActiveWorkbook.Sheets(1).Range("A1").PasteSpecial xlPasteColumnWidths
    ActiveWorkbook.SaveAs FilePath
    ActiveWorkbook.Close False
    Sheet2.Range("G" & WORow).Value = Now 'Update Assigned On to Current date & Time
    
    Application.ScreenUpdating = True
    
    ActiveWorkbook.Save
    
End If

End With
End Sub
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Remove the On Error Resume Next and see where it Errors. Then you should be able to see the problem.
 
Last edited:
Upvote 0
All of your Variables are checking out (Locals Window) as you Step Through?
 
Upvote 0
pic 1 I fill in the field. Then Pic 2 is where I hit save. Pic 3 after saving it fills in the field and suppose to create folder on the desktop.
 

Attachments

  • Pic 1.PNG
    Pic 1.PNG
    81.4 KB · Views: 4
  • pic2.PNG
    pic2.PNG
    84.1 KB · Views: 4
  • pic3.PNG
    pic3.PNG
    78.8 KB · Views: 4
Upvote 0
Try this.
VBA Code:
If IsEmpty(SharedFolder & "\" & AssignedTo) Then MkDir (SharedFolder & "\" Assignedto)
 
Upvote 0
In your code you have Sheet1, Sheet2, Sheet3 and Sheet4. Don't see these in your pictures.
In your pictures you have "Work Order", "WO Data", "Name" and "WO" (all without double quotes).

Do you mean Sheet1 to be "Work Order", Sheet2 to be "WO Data", Sheet3 to be "Name" and Sheet4 to be "WO"?

Maybe explain in a concise manner what you would like to achieve. It can be a daunting task to decipher code to make sense of it sometimes and also guessing that should not be required if the OP explains properly what he/she wants.
 
Upvote 0

Forum statistics

Threads
1,223,879
Messages
6,175,145
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top