• Privacywetgeving
    Het is bij Helpmij.nl niet toegestaan om persoonsgegevens in een voorbeeld te plaatsen. Alle voorbeelden die persoonsgegevens bevatten zullen zonder opgaaf van reden verwijderd worden. In de vraag zal specifiek vermeld moeten worden dat het om fictieve namen gaat.

Commandbutton.onAction

Status
Niet open voor verdere reacties.

riniheijnen

Gebruiker
Lid geworden
20 feb 2012
Berichten
12
I have an excelsheet with a certain range "realusedrange" that has to be pasted in a Powerpint-slide. Because I want to give the user the possibility to make complete the range I made a commandbutton on the excelsheet. When the user presses this button another macro should be started where the pasting happens.

realusedrange.Copy
Cells(lastrow + 2, 3).Select

With Selection
ActiveSheet.buttons.Add(ActiveCell.Left, ActiveCell.Top, 120,60).Select
Selection.OnAction = "PERSONAL.XLSB!macro_powerpoint_slide()"
Selection.Characters.Text = "Powerpoint" & vbCrLf & "Presentatie"
With Selection.Characters(Start:=1, Length:=23).Font
.Name = "Calibri"
.FontStyle = "Standaard"
.Size = 16
End With
End With

Sub macro_powerpoint_slide()

Dim pptApp As PowerPoint.Application
Dim pptPrs As PowerPoint.Presentation
Dim pptSld As PowerPoint.Slide
Dim pptshp As PowerPoint.Shape

Set pptApp = CreateObject("Powerpoint.application")

pptApp.Visible = True

Set pptPrs = pptApp.Presentations.Open("C:\VVVierpolders\automation\Templates\TV-sponsors template." & "potx")
Set pptSld = pptPrs.Slides(1)
Set pptshp = pptSld.Shapes(1)

'plakken excel-tabel in powerpoint slide
pptSld.Shapes.PasteSpecial(ppPasteOLEObject).Select

End Sub

When I run the code I'll get an error

"unable to set the onaction property of the button class"

When I put the text of the second macro at the end of the first macro it works ok for me.
I guess I have to pass "realusedrange"tot the macro "macro_powerpoint_slide()" but I don't know how.
Anyone has any suggesions?
 
En waarom in het Engels? Gezien je eerdere vragen kan je prima Nederlands dus even opnieuw.
 
Ik heb een excelsheet met een range "realusedrange" die geplakt moet worden in een Powerpint-slide. Omdat ik de gebruiker de gelegenheid wil geven de range aan te vullen heb ik op de excelsheet een commandbutton geplaatst. Als de gebruiker hierop clickt wordt er een andere macro gestart waar het plakken gebeurt.

realusedrange.Copy

Cells(lastrow + 2, 3).Select

With Selection
ActiveSheet.buttons.Add(ActiveCell.Left, ActiveCell.Top, 120,60).Select
Selection.OnAction = "PERSONAL.XLSB!macro_powerpoint_slide()"
Selection.Characters.Text = "Powerpoint" & vbCrLf & "Presentatie"
With Selection.Characters(Start:=1, Length:=23).Font
.Name = "Calibri"
.FontStyle = "Standaard"
.Size = 16
End With
End With

Sub macro_powerpoint_slide()

Dim pptApp As PowerPoint.Application
Dim pptPrs As PowerPoint.Presentation
Dim pptSld As PowerPoint.Slide
Dim pptshp As PowerPoint.Shape

Set pptApp = CreateObject("Powerpoint.application")

pptApp.Visible = True

Set pptPrs = pptApp.Presentations.Open("C:\VVVierpolders\automation\Templates\TV-sponsors template." & "potx")
Set pptSld = pptPrs.Slides(1)
Set pptshp = pptSld.Shapes(1)

'plakken excel-tabel in powerpoint slide
pptSld.Shapes.PasteSpecial(ppPasteOLEObject).Select

End Sub

Als ik op de commandbutton klik krijg ik de volgende foutmelding

"eigenschap onAction van klasse button kan niet worden ingesteld "

Als ik de code uit de 2e macro direct achter de eerste zet werkt het wel zoals gewenst is.
Ik denk dat ik de range "realusedrange" door moet geven naar de macro "macro_powerpoint_slide()" allen lukt dat niet goed
Heeft een van jullie suggesties om dit op te lossen>
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan