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

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
For people that come here for help, like you did, and are looking for a solution for a same or similar problem, would you be so kind to show your solution so they will be helped also.
That would be very much appreciated.
Thank you and good luck.
 
Upvote 0
sorry for the late reply i used the code below to correct it
VBA Code:
If Len(Dir("C:\Some folder\path", vbDirectory)) = 0 Then<br>   
 MkDir "C:\Some folder\path"<br>
End If
 
Upvote 0
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at:

There is no need to repeat the link(s) provided above but if you have posted the question at other places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
Thank you for the update. But people with a similar problem that end up here for a solution would sure appreciate the full code so they can sort their problems out.
Would you be willing to help these people by supplying the whole code?
That would be be very much appreciated. Thank you very much for that.
 
Upvote 0

Forum statistics

Threads
1,223,879
Messages
6,175,150
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