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 / Excel / New Users / February 2008

Tip: Looking for answers? Try searching our database.

Help with saving a filename in VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
teepee - 19 Feb 2008 10:51 GMT
If i want to write a macro to save a file as filename x.csv where x is the
value contained in cell b2, I tried

ActiveWorkbook.SaveAs Filename:= _
       "filename "& $b$2 &".csv", FileFormat:=xlCSV,
       CreateBackup:=False

but I'm obviously messing up the syntax. Could anyone set me straight
please? And is there a command to return me to filename.xls afterwards to
continue working?

Many thanks
Gary''s Student - 19 Feb 2008 11:22 GMT
Adapted from the Recorder:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 2/19/2008 by James Ravenswood
'
v = Range("B2").Value
'
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\Owner\My Documents\filename" & v & ".csv",
FileFormat:=xlCSV, _
CreateBackup:=False
   
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\Owner\My Documents\filename" & v & ".xls",
FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
, CreateBackup:=False
End Sub

Signature

Gary''s Student - gsnu2007d

> If i want to write a macro to save a file as filename x.csv where x is the
> value contained in cell b2, I tried
[quoted text clipped - 8 lines]
>
> Many thanks
teepee - 19 Feb 2008 12:22 GMT
Thanks Gary's student.
Gord Dibben - 19 Feb 2008 17:02 GMT
So we finally get a look at the name of Gary's Student?

Gord

>'
>' Macro1 Macro
>' Macro recorded 2/19/2008 by James Ravenswood
>'
>v = Range("B2").Value
Jim Cone - 19 Feb 2008 21:31 GMT
I think he is just teasing us. <g>

Princeton's directory for faculty / students does not have that name.
(Princeton was mentioned in a previous post)

gnsu:  "Gyeongsang National University" does not have a directory
available on their English web site.
Signature

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)

"Gord Dibben" <gorddibbATshawDOTca>
wrote in message
So we finally get a look at the name of Gary's Student?
Gord

On Tue, 19 Feb 2008 03:22:01 -0800, Gary''s Student
<GarysStudent@discussions.microsoft.com> wrote:

>'
>' Macro1 Macro
>' Macro recorded 2/19/2008 by James Ravenswood
>'
>v = Range("B2").Value
Gord Dibben - 19 Feb 2008 23:15 GMT
Could be but the macro recorder doesn't lie<g>

Although one can enter anything in Tools>Options>General>User Name if he wants
to tease.

Gord

>I think he is just teasing us. <g>
>
[quoted text clipped - 3 lines]
>gnsu:  "Gyeongsang National University" does not have a directory
>available on their English web site.
 
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.