Incredibly annoyed but I think I know why it is happening.
All the sudden, this code has been returning TRUE for .FolderExists when its clearly FALSE. The code checks for the directory: ThisWorkbook/Quote Folder/XXXX where XXXX is a unique number.
Quote Folder is completely wiped empty and the code is saying Quote Folder / XXXX exists - There is nothing in Quote Folder
Now, I think this is happening because I have created many backups of my workbook. My workbook is on my desktop in a folder. After every night, I copy the folder and rename to "back up + date". So, i think somehow Excel is confused and it is referencing a completely different path than the current open workbook!!!
Annoying. Any ideas?
CODE:
Dim quotenum As String
quotenum = Sheets("DB_QUOTE").Range("C6").Text
quotefolder = Application.ThisWorkbook.path & "\Quote Files\" & quotenum
With CreateObject("Scripting.FileSystemObject")
If .Folderexists(Application.ThisWorkbook.path & "\Quote Files\" & quotenum) Then
MsgBox "Folder already exists. Please contact system administrator."
ActiveCell.offset(0, 1).Interior.ColorIndex = 30
New_Quote.Hide
Unload New_Quote
Exit Sub
Else
File = .Getfilename(fName)
.CreateFolder quotefolder 'NOTE: FSO cannot create nested folders! Must already have "Quote Files" folder in root or will throw error
'Create New Quote in DataBase
DATASTART.offset(quote_count, 0).Value = CDbl(tb_num) 'CDb1 = convert type to number on input
DATASTART.offset(quote_count, 1).Value = today
DATASTART.offset(quote_count, 4).Value = "Open"
DATASTART.offset(quote_count, 51) = "None"
Sheets("DB_QUOTE").Range("C6").Value = CDbl(tb_num)
New_Quote.Hide
Unload New_Quote
Load Edit_Quote
Edit_Quote.Show
End If
End With
End Sub
Bookmarks