Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 23rd, 2012, 10:43 AM
rachelm920 rachelm920 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2009
Location: Hartford, Connecticut, USA
Posts: 12 rachelm920 User rank is Sergeant (500 - 2000 Reputation Level)rachelm920 User rank is Sergeant (500 - 2000 Reputation Level)rachelm920 User rank is Sergeant (500 - 2000 Reputation Level)rachelm920 User rank is Sergeant (500 - 2000 Reputation Level)rachelm920 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 1 m 24 sec
Reputation Power: 0
Facebook MySpace
Copy an Excel file adding yesterday's date

I want to copy an excel file and rename it with yesterday's date. Such as test 02-22-12.xlsx

I have most of the code working, but for some reason it names it test 00-22-12.xlsx I don't know why it is using 00 for the month... Maybe a more advanced VBA user can assist. I am using Visual Basic 2010.

Code:
Module test 
Sub Main() 
'Copy and Rename the report' 
My.Computer.FileSystem.CopyFile("C:\Test.xlsx", "C:\Test " & Format(DateAdd("d", -1, Today()), "mm-dd-yy") & ".xlsx", FileIO.UIOption.AllDialogs, FileIO.UICancelOption.DoNothing) End Sub End Module

Reply With Quote
  #2  
Old February 23rd, 2012, 11:22 AM
rachelm920 rachelm920 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2009
Location: Hartford, Connecticut, USA
Posts: 12 rachelm920 User rank is Sergeant (500 - 2000 Reputation Level)rachelm920 User rank is Sergeant (500 - 2000 Reputation Level)rachelm920 User rank is Sergeant (500 - 2000 Reputation Level)rachelm920 User rank is Sergeant (500 - 2000 Reputation Level)rachelm920 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 1 m 24 sec
Reputation Power: 0
Facebook MySpace
I figured it out myself, but decided to keep it on here to help someone else....

Code:
Module test

    Sub Main()
Dim yourdate As Object 
'Date format' 
yourdate = Format(DateAdd("d", -1, Today()), "MM-dd-yy") 
'Copy and Rename the report' 
My.Computer.FileSystem.CopyFile("C:\Test.xlsx", "C:\Test " & yourdate & ".xlsx", FileIO.UIOption.AllDialogs, FileIO.UICancelOption.DoNothing)

End Sub
End Module
Comments on this post
medialint agrees: thanks for following up

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Copy an Excel file adding yesterday's date

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap