Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

violating any best practices etc.?

Status
Not open for further replies.

imarosel

Technical User
Jun 23, 2005
149
US
Sub BackupByDate()
Dim dname As String, strTest As String
dname = ThisWorkbook.Path & "\B" & Format(Now(), "yyyy_mmdd")
strTest = Dir(dname, vbDirectory)
If (strTest = "") Then MkDir (dname)
ActiveWorkbook.SaveCopyAs dname & "\BK_" & Format(Now(),"hh") & "." & Format(Now(),"mm") & "." & Format(Now(), "ss") & "_" & ActiveWorkbook.Name
ActiveWorkbook.Save 'also save current file
End Sub

slightly modified from what I found here:
 
Yep multiple bad practices this looks more like vb6 then vb.net.

format, dir and mkdir should be replaced.

where do the workbooks come from. Does it actually work.


Christiaan Baes
Belgium

My Blog
"In a system where you can define a factor as part of a third factor, you need another layer to check the main layer in case the second layer is not the base unit." - jrbarnett
 
works great, this is for a macro in an excel spreadsheet, don't think that is vb.net. Maybe I'm in the wrong forum?
 
Yes you are in the wrong forum.


Christiaan Baes
Belgium

My Blog
"In a system where you can define a factor as part of a third factor, you need another layer to check the main layer in case the second layer is not the base unit." - jrbarnett
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top