Help me please :-)

Dave1988

New Member
Joined
Aug 1, 2017
Messages
4
Hello,

I am trying to write a bit of code to place a file that I have saved within the code as an attachment on a email and extract the address from the file to place in the to box.

this is the code as it stands: -
Sub SaveAndEmail()
Dim NewFN As Variant
NewFN = "O:\Sports Centre\Purchase Order\Copies of Orders\Orders - Sports" & Range("J5").Value & ".pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:=NewFN, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False


Range("J5").Value = Range("j5").Value + 1

Range("C8:D12").ClearContents
Range("G8:J8").ClearContents
Range("B15:H32").ClearContents
Range("D34:E38").ClearContents

ThisWorkbook.Save

Application.Quit


End Sub

also does anyone know if there is a way to select a print within macro coding instead of just sending to the default printer?
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Regarding the PRINT portion of your query:

Include Code line:

Code:
Application.Dialogs(xlDialogPrinterSetup).Show
 
Last edited:
Upvote 0
I'm out of my office at present. Will be back within the hour. I'll send you the code then. Jim
 
Upvote 0
The easiest way to get the code for this (including the path to the printer) will be for you to record a macro.

1.Click on Record Macro
2.Run through the print process including changing the printer to print to
3.Stop recording
4.Review your macro

This will include the code string:
Application.ActivePrinter = "YOUR PRINTER PATH"

Then insert this in your code above

Hope this helps...

Jim
 
Upvote 0
The easiest way to get the code for this (including the path to the printer) will be for you to record a macro.

1.Click on Record Macro
2.Run through the print process including changing the printer to print to
3.Stop recording
4.Review your macro

This will include the code string:
Application.ActivePrinter = "YOUR PRINTER PATH"

Then insert this in your code above

Hope this helps...

Jim

thanks all working now...
just to work out how to do the email bit..
 
Upvote 0

Forum statistics

Threads
1,223,902
Messages
6,175,278
Members
452,629
Latest member
SahilPolekar

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