I want to store today value in a string in VBA Word, e.g. today is Oct 04 2012, the string will be = "04102012". Any simple code can achieve that?


Recommended Answers

All 3 Replies

You would use something like -

Sub FormatNow()
    Dim myWorksheetName As String
    myWorksheetName = Format(Now, "mmmm_yyyy")
    MsgBox myWorksheetName
End Sub

Thanks, the code works perfectly well!

    Dim dateStr As String    
    dateStr = Format(Now, "ddmmyyyy")

Only a pleasure. Please mark as solved thanx.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.