Ask Experts Questions for FREE Help!
 

Free Answers in 3 Easy Steps

Register Now
3 Steps
 


Ask QuestionsprogressAnswer QuestionsprogressBuild ReputationprogressBecome an Expert
 
At Ask Me Help Desk you can ask questions in any topic and have them answered for free by our experts. To ask questions or participate in answering them you must register for a free account. By registering you will be able to:
  • Get free answers from experts in any of our 300+ topics.
  • Accept money for answers that you provide.
  • Communicate privately with other members (PM).
  • See fewer ads.
  Answer this Question    Ask about Visual Basic    Ask about another Subject  
 

colbtech
Aug 7, 2009, 07:07 AM
I know I'm being thick but, the following "almost" works. For some reason the string is not stored in the cell specified, yet the string length is saved and the msgbox shows the values to exist. What's going on? It's Friday I'm close to tears, the sun is shining and I'm off next week.




Private Sub CheckDirectory()

VarYear = Right(Date$, 4) ' Get the year
DoesTopDirExist = "\\OLDSERVER\Climate\Sales Orders (New)" ' Set base directory
If Len(Dir(DoesTopDirExist, vbDirectory)) = 0 Then ' Does the directory exist?
MkDir DoesTopDirExist ' if not create the directory
End If

DoesDirExist = DoesTopDirExist & "\Sales Orders " & VarYear ' Create an annual directory
If Len(Dir(DoesDirExist, vbDirectory)) = 0 Then ' Does the directory exist
MkDir DoesDirExist ' if not create it
End If
Sheet2.Cells(25, 253).Value = Len(DoesDirExist) ' save the length of the string
Sheet2.Cells(24.253).Value = DoesDirExist ' save the string (should be "\\OLDSERVER\Climate\Sales Orders (New)\Sales Order 2009")

MsgBox "File sub - " & DoesDirExist & " - " Len(DoesDirExist) 'Msgbox show "File sub - \\OLDSERVER\Climate\Sales Orders (New)\Sales Order 2009 - 55"

End Sub

colbtech
Aug 7, 2009, 08:22 AM
Sorted......AAAARGH! No more tears, pub is calling. Amazing what a full stop instead of a comma does to code!!!!!!