Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual 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 ASP Free Forums Sponsor:
  #1  
Old January 27th, 2005, 03:23 PM
roughneck82 roughneck82 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Tejas
Posts: 63 roughneck82 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 32 m 5 sec
Reputation Power: 5
VB EXCEL question / saving file

I have this code in a macro where it is to save the file automatically for me at work.
On the worksheet named Allen and the Cell B2 is a date.
Code:
 
Sub SaveFile()
	Dim myRange As Variant
	Set myRange = Sheets("Allen").Range("B2")
	Dim MyMonth, MyDay, Filename, SaveDate, NewFileName, usableDate
	usableDate = myRange
	MyMonth = Month(usableDate)
	MyDay = Day(usableDate)
	Filename = "AgentAux_"
	SaveDate = MyMonth + MyDay
	NewFileName = Filename + SaveDate
	ChDir "P:\--WorkForce\Staffing"
	ActiveWorkbook.SaveAs Filename:=NewFileName, FileFormat:=xlNormal
	ActiveWindow.Close
	MsgBox ("File saved in Staffing Folder")
End Sub
 

I always run into an error when I'm trying to set the variable MyMonth to the number of Month in the cell B2
For Example the file will be saved in that directory with the NewFilename = AgentAux_ddmm
Any help will be appreciated

Reply With Quote
  #2  
Old January 27th, 2005, 05:57 PM
JamesLe JamesLe is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Oakland, CA, USA
Posts: 131 JamesLe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m
Reputation Power: 5
Hello roughneck82,


Using "&" instead of "+" for string concate. For example

SaveDate = MyMonth + MyDay
NewFileName = Filename + SaveDate

Should be:

SaveDate = MyMonth & MyDay
NewFileName = Filename & SaveDate

Reply With Quote
  #3  
Old January 28th, 2005, 02:28 AM
roughneck82 roughneck82 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Tejas
Posts: 63 roughneck82 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 32 m 5 sec
Reputation Power: 5
Alright thanks a bunch I will try that

Reply With Quote
  #4  
Old January 28th, 2005, 12:19 PM
roughneck82 roughneck82 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Tejas
Posts: 63 roughneck82 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 32 m 5 sec
Reputation Power: 5
MyMonth = Month(usableDate)
MyDay = Day(usableDate)


That is the part the always has an error. The part where I'm trying to convert the Month and Day

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > VB EXCEL question / saving file


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT