Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Append date to auto-generated Excel sheet

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jamesftoland@gmail.com - 13 Jan 2006 23:03 GMT
Hi

I have a macro that translates table data into a newly created Excel
worksheet, and saves the name of the xls in the format of the name of
the word doc that spawned it, save for losing the .doc extension and
appending the the designation "_log_" and the current date.

Example: Word doc titled "VBA Question.doc" generates spreadsheet
called "VBA Question_log_01-13-06.xls

Here is the code I used to do this, which seems like it should work,
yet obviously does not:

'extract name of current active document and specify the name of excel
doc to save to
cwfile = ActiveDocument.FullName 'get current file name and path
cwfile = Left(cwfile, Len(cwfile) - 4) 'get rid of extension
formattedDate = Left(Date, 2) & "-" & Mid(Date, 4, 2) & "-" &
Right(Date, 4) 'get date and format
cwfile = cwfile & "_log_" & formattedDate & ".xls" 'full excel filename

It gets the name, but garbles up in the date extension, and misses the
.xls extension altogether.

What obvious mistake am I making? Or is there a cleaner way to do this?

Thanks, I love this place
Doug Robbins - Word MVP - 14 Jan 2006 08:28 GMT
cwfile = cwfile & "_log_" & Format(Date, "MM-dd-yy") & ".xls"

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Hi
>
[quoted text clipped - 23 lines]
>
> Thanks, I love this place
jamesftoland@gmail.com - 16 Jan 2006 17:53 GMT
Doug,

Worked like a champ.

You are a rockstar.

Thanks!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.