Thread: SaveAs
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
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