LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Save worksheet to a unique filename after worksheet is printed

Thanks for your help ... works great.

Is it possible to save the worksheet in the background (don't want the
Save As dialog box to appear) and then print it to the default printer?



okrob wrote:
Sorry, on the wscopy sub, you don't need to dim SBookName
That was left over in my original workbook code.
Rob


okrob wrote:
May be a little more than you asked for, but you can always
remark/delete the stuff you don't need.
Rob

++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++
Sub MD()
On Error GoTo done
MkDir "C:\YourPath\"
'<=== Change "YourPath" to where you save the files
done:
End Sub

Sub wscopy()
Call MD
Dim SBookName
Dim tdate As String
tdate = Format(Date, "ddmmyyyy")

Dim rng1 As String, rng2 As String, rng3 as String
rng1 = Range("A1").Value
rng2 = Range("A2").Value
rng3 = Range("B1").Value

Dim FN As Variant
ActiveSheet.Copy
With Application
FN = .GetSaveAsFilename _
("C:\YourPath\" & rng1 & rng2 & rng3 & "_" & tdate & ".xls")
'<=== Change "YourPath" to where you save the files
If FN < False Then
ActiveWorkbook.SaveAs FN
End If
End With
' Unmark the next line to attach the file to an email using your
default email client
' Application.Dialogs(xlDialogSendMail).Show

End Sub
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++


Lifestyle wrote:
I have a worksheet where cell "B1" automatically generates a unique
number (i.e. like an invoice number). I would like to have a command
button (as well using the File|Print) to print the worksheet as well as
saving the worksheet to a unique filename which includes whatever is in
cell A1 and A2 as well as the date that it was printed. i.e. A1 = PAS,
B1 = 001 then the filename should be PAS001_ddmmyyy.xls.

I do not want to save the whole workbook to the new filename but only
the individual worksheet.

Thank you


 
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
How to show date printed, updated only when worksheet printed? Sam Excel Discussion (Misc queries) 4 April 4th 23 10:49 AM
Auto save file copy with unique filename Allen Excel Worksheet Functions 1 June 27th 06 08:18 PM
USE MACRO TO SAVE WORKSHEET SELECTING FILENAME FROM CELLS David Vollmer Excel Programming 18 September 10th 05 03:32 PM
How do i auto rename a worksheet to be the same filename as save f Catherine Excel Worksheet Functions 1 December 1st 04 10:17 AM
using macro to save worksheet with unique file name Noell Excel Programming 3 October 15th 03 10:24 PM


All times are GMT +1. The time now is 07:31 AM.

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"