dss28
Board Regular
- Joined
- Sep 3, 2020
- Messages
- 165
- Office Version
- 2007
- Platform
- Windows
I am able to copy a part of the sheet and print separately using command
Application.Dialogs(xlDialogPrinterSetup).Show
ActiveSheet.PrintOut
I am also able to copy and email the selection using following code
however I want to combine these two codes and do both the things in one command button tp prevent the user to see or modify the sheet.
I am trying to include one part of code (printing) through main userform command button - can select printer and print. After Printing I am calling another userform to open and placed my copy / email code in it. It has two command buttons - "Yes" - to copy and email and second "No"- exit without copying / emailing
However the second userform called through first userform is not copying the data but opens the outlook email.
Only the copy range code does not work.
please suggest way out.
Application.Dialogs(xlDialogPrinterSetup).Show
ActiveSheet.PrintOut
I am also able to copy and email the selection using following code
VBA Code:
With Sheet13
'======================================= copy zone ==============================
.Range("B3:Q23").Select
Selection.Copy
'========================================================== email copied data =======================
On Error Resume Next
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = "Body content" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2"
On Error Resume Next
With xOutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = " xxxx "
.Body = " yyyy"
.display 'or use .Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
'=========================== email code ends===================================
End With
however I want to combine these two codes and do both the things in one command button tp prevent the user to see or modify the sheet.
I am trying to include one part of code (printing) through main userform command button - can select printer and print. After Printing I am calling another userform to open and placed my copy / email code in it. It has two command buttons - "Yes" - to copy and email and second "No"- exit without copying / emailing
However the second userform called through first userform is not copying the data but opens the outlook email.
Only the copy range code does not work.
please suggest way out.