Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Visual Basic (https://www.askmehelpdesk.com/forumdisplay.php?f=469)
-   -   Vb strings in excel (https://www.askmehelpdesk.com/showthread.php?t=384350)

  • Aug 7, 2009, 07:07 AM
    colbtech
    vb strings in excel
    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
  • Aug 7, 2009, 08:22 AM
    colbtech

    Sorted... AAAARGH! No more tears, pub is calling. Amazing what a full stop instead of a comma does to code!!

  • All times are GMT -7. The time now is 04:38 PM.