Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default VBA for saving a file to a specific location

Works awsome thank you so much Dave!

"Dave Peterson" wrote:

Maybe...

'delete the chdir line, you don't need it
ActiveWorkbook.SaveAs filename:= _
"L:\Tax Department\Clients\Symbol Technologies\Adjustment Imports\" _
& fname, _
FileFormat:=xlTextPrinter, CreateBackup:=False

By including the fname inside the quotes, excel saw it as part of the
string--not a variable.


TimT wrote:

I need help on the syntax:
how come when I replace the filename "book1.prn" with "filename" (the
string) it saves it as "filename" and not the concatenation that I declared
it to be?

Dim fname As String
With Worksheets("intro")

fname = "Symbol_" & .Range("month_entry").Value &
.Range("yr_entry").Value
End With

ChDir "L:\Tax Department\Clients\Symbol Technologies\Adjustment Imports"
ActiveWorkbook.SaveAs filename:= _
"L:\Tax Department\Clients\Symbol Technologies\Adjustment
Imports\fname", _
FileFormat:=xlTextPrinter, CreateBackup:=False


"Dave Peterson" wrote:

Record a macro when you save it as .prn and you'll see the code.

I got this:

ActiveWorkbook.SaveAs Filename:="C:\My Documents\excel\Book1.prn", _
FileFormat:=xlTextPrinter, CreateBackup:=False

So I could just change the filename...

ActiveWorkbook.SaveAs Filename:=myfilename, _
FileFormat:=xlTextPrinter, CreateBackup:=False

Remember to activate the correct worksheet first. (.Prn's will only save the
activesheet.)

TimT wrote:

Thanks!
What about making it default to .prn file format?

"Dave Peterson" wrote:

Dim myFileName as string
with worksheets("sheet1")
myfilename = .range("month_entry").value & .range("year_entry").value
end with

Then use myfilename in your SaveAs line.

TimT wrote:

I'm using Excel 2003 and I'm recording a macro.
At the end of the macro I need to save the file to a specific location and
use the concatenation of two range names for the file name.
Does anyone know how the code should look like for this assuming:
location is "L:\Clients\symbol\"
range names are "month_entry" & "year_entry"
Please help!

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving file to a location determined by a cell Dan Hulgin Excel Programming 1 October 28th 04 10:24 PM
Saving file to a location determined by a cell Goppi[_6_] Excel Programming 0 October 28th 04 01:16 PM
Saving file to a location determined by a cell Dan Hulgin[_3_] Excel Programming 1 October 28th 04 01:01 PM
Saving file to a location determined by a cell Dan Hulgin[_2_] Excel Programming 0 October 26th 04 08:46 PM
Saving a TXT file keeping its current location Chichifo[_3_] Excel Programming 1 September 7th 04 07:39 PM


All times are GMT +1. The time now is 04:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"