2 Things: VBA Formula to Convert 1 excel sheet to .pdf and mail from Outlook & Clear Contents from Cell

dasmith7

New Member
Joined
May 13, 2016
Messages
7
Hi,
I have scanned the forums, but nothing fits my criteria. I want to know if there is a VBA formula to convert 1 sheet in an Excel workbook to pdf and mail through Outlook. I do not want the code to attempt to SAVE the .pdf to my drive. I only want it to convert the sheet to pdf and create a new email only.

#2: Is there a formula or VBA code that will simply clear the contents of a cell. I have a workbook that employees enter their id and pull there monthly numbers. Once the id is entered, all fields automatically populate. Is there a VBA that i can use to simply clear the cell that has the ID? I want to link the CLEAR VBA to a command button. Once the employee emails their monthly numbers themselves, the employee can press CLEAR to delete their ID and data prior to someone viewing their information.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Code:
' sheet module
Private Sub CommandButton1_Click()
[e4].ClearContents
End Sub
 
Upvote 0
#1

Is the following method acceptable for you?

- Create pdf to drive
- Send mail
- Delete pdf file
 
Upvote 0
Thanks, however ,is this the entire code? When I enter module, i get a COMPILE error message.
No, it isn't the complete code. I thought you must have already had something for your Command Button & just needed the line to clear the cell.

It depends whether your Command Button is
- an ActiveX Command button: proceed as suggested by Worf
or
- a Form Control Command Button. If so, put the following in a Standard Module then right click your Command Button, choose 'Assign Macro..' , select the Clear_Cell macro, OK

Code:
Sub Clear_Cell()
  Range("D5").ClearContents
End Sub
 
Upvote 0
#1

Is the following method acceptable for you?

- Create pdf to drive
- Send mail
- Delete pdf file

Hi,
Thank you for the response. I would prefer not to have a save option ("Create pdf to drive). I only want send email with a copy of the worksheet in .pdf format. I already have a VBA code to send a copy of the worksheet in excel, but not in pdf.
 
Upvote 0
As far as I know, Office will always create a pdf file to disk before emailing it. Even when the user does not explicitly saves a copy, such as doing file > share > mail > send as PDF, a file is created on a temporary location.

You will have to delete the unwanted file later; this can be done by code.

Would you like an example?
 
Upvote 0
As far as I know, Office will always create a pdf file to disk before emailing it. Even when the user does not explicitly saves a copy, such as doing file > share > mail > send as PDF, a file is created on a temporary location.

You will have to delete the unwanted file later; this can be done by code.

Would you like an example?

Yes, i would like the code. thank you!
 
Upvote 0

Forum statistics

Threads
1,213,504
Messages
6,114,020
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top