View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Josh Johansen Josh Johansen is offline
external usenet poster
 
Posts: 72
Default Programing a button in excel

Also, I have moved the pivot table down 8 cells in order to put some
extensive calculations on the top so that I could lock them and wherever the
user was on the pivot table they could see these calculations, is there any
way to include them on the copy, paste and email? Thanks again.

"Tom Ogilvy" wrote:

Recipient should be plural: Recipients

also, you seem to have a typo in the Workbooks.Add Line. The constant is

Workbooks.Add Template:=xlWBATWorksheet

not

Workbooks.Add Template:=zlWBATWorksheet

--
Regards,
Tom Ogilvy


"Josh Johansen" wrote:

Here is what I copied:

Private Sub CommandButton1_Click()
Set rng = ActiveSheet.PivotTables(1).TableRange2
Workbooks.Add Template:=zlWBATWorksheet
ActiveSheet.Range("A1").Select
rng.Copy
Activesheeet.PasteSpecial xlValues
ActiveSheet.PasteSpecial xlFormats
ActiveWorkbook.SendMail Subject:="Scheduling", "
ActiveWorkbook.Close SaveChanges:=False
End Sub

When I attempt to use the button I am getting. "Compile error, named
argument not found." with the recipient portion highlighted. I have to admit
I am not at all familiar with Visual Basic, what am I doing wrong? Thanks
again.

"Tom Ogilvy" wrote:

ActiveSheet.PivotTables(1).TableRange2.Copy

will copy the data in the pivot Table including pagefields. If you don't
want the pagefields, then use TableRange1

I might use something like:

set rng = ActiveSheet.PivotTables(1).TableRange2
workbooks.Add Template:=xlWBATWorksheet
Activesheet.Range("A1").Select
rng.copy
Activesheet.PasteSpecial xlValues
Activesheet.PasteSpecial xlFormats
ActiveWorkbook.Sendmail Subject:="Myfiles", "
Activeworkbook.close SaveChanges:=False





--
Regards,
Tom Ogilvy


"Josh Johansen" wrote:

I guess the thing I am unsure how to do is write a program that will select
the data currently displayed in the pivot table, copy that data, paste it to
a new mail message all with a programmed button. Because various users will
be using the pivot table, the size could be extremely different, I will read
through the link you left me and hopefully find some useful information,
thank you so much.

"Tom Ogilvy" wrote:

Take a look at Ron de Bruin's site:

http://www.rondebruin.nl/sendmail.htm

this has extensive information on mailing data from Excel. Your description
isn't very definitive, so you will have to decide what is appropriate.

--
Regards,
Tom Ogilvy


"Josh Johansen" wrote:

I would like to program a button that will copy a pivot table, and then paste
it into a new email message. This will prevent the users from being confused
with all the steps this would take manually. I am not too familiar with how
to do this, any ideas? Thanks.