#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default SaveAs

If you're using xl97, then show the properties for that commandbutton and change
its "takefocusonclick" property to false. (A bug in xl97 that was fixed in
xl2k.)

But that underscore and ampersand are important.

The underscore means that the VBA statement is continued on the next line. The
ampersand means that we're taking two things and jamming them together
(concatenating).

ActiveWorkbook.SaveAs Filename:="C:\" _
worksheets("sheet1").range("a1").value & ".xls"

Make sure you didn't delete the space in front of the underscore either. (and
if the cell contained .xls, you wouldn't need this -- & ".xls"

And watch out for this: f9:g9. You're looking at two cells and can't pick up
the value this way.

If one of them contained the folder and one contained the filename, this format
would be closer:

ActiveWorkbook.SaveAs Filename:="C:\" _
worksheets("sheet1").range("f9").value & _
worksheets("sheet1").range("g9").value & ".xls"

If this doesn't work for you, then include what's in those two cells in your
next post.



Darrin Henry wrote:

This is what I have now, the command button invokes the save. However,
the "_" and "&" do not work, I had to remove them, I don't know if they
are needed or not. Also I get a Run-time error '1004'. The contents of
the cell is going to be something like CCHenry091003. Thanks.
Private Sub CommandButton1_Click()

ActiveWorkbook.SaveAs Filename:="C:\"
Worksheets("sheet1").Range("f9:g9").Value ".xls"
End Sub

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


--

Dave Peterson

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default SaveAs

Thanks, that worked perfectly the main problem was the merged cells.
When I unmerged them, it worked perfectly. Now I've had one of my users
throw in a monkey wrench. What if a file with the same name exists. I'm
thinking I need to declare the proper variable then check to see if a
file that equals the variable exists, but I don't know how to check
that. Can anyone help?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
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
Using SaveAs SarahN Excel Discussion (Misc queries) 3 May 14th 10 04:26 AM
SaveAs - VBA Jae[_3_] Excel Discussion (Misc queries) 4 April 10th 08 08:10 PM
SaveAs - VBA Jae Excel Discussion (Misc queries) 0 April 10th 08 06:04 AM
VBA SaveAs Value charlie Excel Discussion (Misc queries) 4 August 27th 07 11:33 PM
SaveAs Stan Halls Excel Worksheet Functions 5 November 28th 06 07:51 PM


All times are GMT +1. The time now is 10:42 PM.

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

About Us

"It's about Microsoft Excel"