PC Review


Reply
Thread Tools Rate Thread

saving a worksheet as a .txt file with filename of specified cell

 
 
meghantrus@hotmail.com
Guest
Posts: n/a
 
      3rd Mar 2008
I am trying to save one worksheet in my workbook as a .txt file. I
want the name of the file to equal
Worksheets("Weekly").Range("A1"). (which will change montly, that's
why it cannot be a static defined name)
My Macro runs, but the problem is that it always equals the name of my
variable, which is "ThisFile". I need to save it in a specific
location U:\myfolder\ThisFile
Please review code below and provide assistance if you can.
Thanks!


Sub createplan()

ThisFile = Worksheets("Weekly").Range("A1")
ActiveWorkbook.SaveAs Filename:= _
"U:\myfolder\ThisFile", FileFormat:=xlText _
, CreateBackup:=False

End Sub
 
Reply With Quote
 
 
 
 
turbonate@gmail.com
Guest
Posts: n/a
 
      3rd Mar 2008
On Mar 3, 1:10 pm, meghant...@hotmail.com wrote:
> I am trying to save one worksheet in my workbook as a .txt file. I
> want the name of the file to equal
> Worksheets("Weekly").Range("A1"). (which will change montly, that's
> why it cannot be a static defined name)
> My Macro runs, but the problem is that it always equals the name of my
> variable, which is "ThisFile". I need to save it in a specific
> location U:\myfolder\ThisFile
> Please review code below and provide assistance if you can.
> Thanks!
>
> Sub createplan()
>
> ThisFile = Worksheets("Weekly").Range("A1")
> ActiveWorkbook.SaveAs Filename:= _
> "U:\myfolder\ThisFile", FileFormat:=xlText _
> , CreateBackup:=False
>
> End Sub


Use the & sign to concatenate strings:

Sub createplan()

ThisFile = Worksheets("Weekly").Range("A1")
ActiveWorkbook.SaveAs Filename:= _
"U:\myfolder\" & ThisFile, FileFormat:=xlText _
, CreateBackup:=False

End Sub

Cheers!
Nate
 
Reply With Quote
 
 
 
Reply

Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HttpPostedFile.saveas(filename) issue when the filename is used "-" as a part of the filename. Ken Microsoft Dot NET Framework 0 25th Feb 2009 11:58 PM
Cell("filename") doesn't update to new filename when do save as. =?Utf-8?B?TG91aXM=?= Microsoft Excel Worksheet Functions 2 22nd Mar 2007 08:27 PM
saving workbook with specified filename on the romote server Magdalena Biernacka Microsoft Excel Programming 1 3rd Jun 2004 10:18 AM
saving file with new filename based on current filename Michael J. Malinsky Microsoft Excel Programming 5 18th Mar 2004 01:34 PM
Saving filename same as import filename =?Utf-8?B?TWF0dA==?= Microsoft Excel Programming 4 24th Feb 2004 04:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:50 PM.