twitter




Monday, October 12, 2009

In MS Excel i want to add a button into a worksheet that Prints the worksheet and allows the user to email me?

How do i create a macro that does this as when i recorded one for print it takes them to the print preview screen and needs them to click print for it to continue. When i recorded an email button macro, i chose send to option and set up an email and sent it and stopped macro. This button does not work currently. any ideas?
In MS Excel i want to add a button into a worksheet that Prints the worksheet and allows the user to email me?
You will need more than this to do what you want


First, add a module, and paste this into it


Sub PrintPreview()


Application.ScreenUpdating = False





ActiveSheet.PageSetup.PrintArea = "$E$9:$K$20"


With ActiveSheet.PageSetup


.LeftHeader = ""


.CenterHeader = ""


.RightHeader = ""


.LeftFooter = ""


.CenterFooter = ""


.RightFooter = ""


.LeftMargin = Application.InchesToPoints(0.74803149606...


.RightMargin = Application.InchesToPoints(0.74803149606...


.TopMargin = Application.InchesToPoints(0.98425196850...


.BottomMargin = Application.InchesToPoints(0.98425196850...


.HeaderMargin = Application.InchesToPoints(0.51181102362...


.FooterMargin = Application.InchesToPoints(0.51181102362...


.PrintHeadings = False


.PrintGridlines = False


.PrintComments = xlPrintNoComments


.PrintQuality = 600


.CenterHorizontally = True


.CenterVertically = False


.Orientation = xlLandscape


.Draft = False


.PaperSize = xlPaperA4


.FirstPageNumber = xlAutomatic


.Order = xlDownThenOver


.BlackAndWhite = False


.Zoom = False


.FitToPagesWide = 1


.FitToPagesTall = 1


End With





Application.ScreenUpdating = True


End Sub





This will set the PageSetup settings for your sheet


To print with current settings just add this line


ActiveSheet.PrintOut





Now for sending mail, you will need to use some external DLLs for this


you will need to send me your e-mail through Y! Answers to send you the files.





Enjoy my profile, I am the VBAXLMan
Reply:Hi the printing is quite easy.





1. Insert a picture saying Print. (It's easier to use a picture)


2. Right-click on picture and sau "Assign Macro"


3. If you want it to pop the Print box, where you can select another printer and the amount of copies, type :


Application.Dialogs(xlDialogPrint).Sho...





(hover you mouse over the command above to see the whole thing, for some reason I'm getting ... the whole time)





4. If you allready got a Print rage selected, and you know the printer is default, and you just want it to print you want to use one of the following :





activeworksheet.printout


activeworkbook.printout





5. That's it for printing...





To mail you is quite easy, just type in the one cell


Email :


and then to the cell next to it, type your email adress. If the person click on you mail adress, his outlook/outlook express will open by it self.





Hope this helped a little, put more info, if you ment something else with the mail...

No comments:

Post a Comment