Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Using SaveAs | Excel Discussion (Misc queries) | |||
SaveAs - VBA | Excel Discussion (Misc queries) | |||
SaveAs - VBA | Excel Discussion (Misc queries) | |||
VBA SaveAs Value | Excel Discussion (Misc queries) | |||
SaveAs | Excel Worksheet Functions |