Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Save file, refer filename to cell and change directory

Hi

I have the following macro to change my filename

Sub save_with_cell(
Dim fnam
fname = Worksheets("General info").Range("C47").Value & "#" & Range("C26").Valu
fname = fname & ".xls
ActiveWorkbook.SaveAs Filename:=fnam
End Su

I want also get my file saved in a specific folder in a other directory. Can anybody tell me how to do that
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Save file, refer filename to cell and change directory

Hi
try

Sub save_with_cell()
Dim fname
Dim path
path "C:\temp\"
fname = Worksheets("General info").Range("C47").Value
& "#" & Range("C26").Value
fname = fname & ".xls"
ActiveWorkbook.SaveAs Filename:=path & fname
End Sub

-----Original Message-----
Hi,

I have the following macro to change my filename.

Sub save_with_cell()
Dim fname
fname = Worksheets("General info").Range("C47").Value

& "#" & Range("C26").Value
fname = fname & ".xls"
ActiveWorkbook.SaveAs Filename:=fname
End Sub

I want also get my file saved in a specific folder in a

other directory. Can anybody tell me how to do that
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Save file, refer filename to cell and change directory


Hi Frank

It didn't work. I got the message "Compile error: Expected Sub, function or property" and the word path is marked yellow
----- Frank Kabel wrote: ----

H
tr

Sub save_with_cell(
Dim fnam
Dim pat
path "C:\temp\
fname = Worksheets("General info").Range("C47").Value
& "#" & Range("C26").Valu
fname = fname & ".xls
ActiveWorkbook.SaveAs Filename:=path & fnam
End Su

-----Original Message----
Hi
I have the following macro to change my filename
Sub save_with_cell(

Dim fnam
fname = Worksheets("General info").Range("C47").Value

& "#" & Range("C26").Valu
fname = fname & ".xls
ActiveWorkbook.SaveAs Filename:=fnam
End Su
I want also get my file saved in a specific folder in a

other directory. Can anybody tell me how to do tha


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Save file, refer filename to cell and change directory

A couple of typos:

Option Explicit

Sub save_with_cell()
Dim fname As String
Dim myPath As String

myPath = "C:\temp\"
fname = Worksheets("General info").Range("C47").Value _
& "#" & Range("C26").Value
fname = fname & ".xls"
ActiveWorkbook.SaveAs Filename:=myPath & fname
End Sub

(I wouldn't use a variable named Path. It's too close to the VBA property named
Path!)



Metin wrote:

Hi Frank,

It didn't work. I got the message "Compile error: Expected Sub, function or property" and the word path is marked yellow.
----- Frank Kabel wrote: -----

Hi
try

Sub save_with_cell()
Dim fname
Dim path
path "C:\temp\"
fname = Worksheets("General info").Range("C47").Value
& "#" & Range("C26").Value
fname = fname & ".xls"
ActiveWorkbook.SaveAs Filename:=path & fname
End Sub

-----Original Message-----
Hi,
I have the following macro to change my filename.
Sub save_with_cell()

Dim fname
fname = Worksheets("General info").Range("C47").Value

& "#" & Range("C26").Value
fname = fname & ".xls"
ActiveWorkbook.SaveAs Filename:=fname
End Sub
I want also get my file saved in a specific folder in a

other directory. Can anybody tell me how to do that
.


--

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
Save file to same directory folder RobN[_2_] Excel Discussion (Misc queries) 2 April 4th 10 08:06 AM
file save error: the file or directory cannot be created dublg Excel Discussion (Misc queries) 1 September 25th 06 07:07 PM
Automatically save a file in another directory MarkT Excel Discussion (Misc queries) 4 September 18th 06 02:53 PM
Save excel file with filename = cell text TroyB[_2_] Excel Programming 1 November 26th 03 01:00 AM
get path - save new file - same sub-directory as existing file tegger Excel Programming 2 October 21st 03 10:45 AM


All times are GMT +1. The time now is 09:01 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"