powerpoint-vba

Windows keyboard hook API in VBA causes infinite loop in PowerPoint

余生颓废 提交于 2020-03-05 02:52:27
问题 I've built a simple VBA module to set a keyboard hook and a corresponding procedure to detect a pre-defined key combination (ctrl+3). It works perfectly except that when a user tries types in a window of the hosting app (PowerPoint), the code runs into an infinite loop causing the app to hang/crash. Here is the complete module with reproduction instructions: ' =========================================================================== ' Module : MOD_Keyboard_Shortcuts ' Purpose : Create pre

VBA Office2010 Shapes.PasteSpecial fails

蹲街弑〆低调 提交于 2020-02-04 04:04:12
问题 I have a problem while migrating my VBA code from Office2003 to Office2010. I would like to copy the text of a cell (Excel) to Powerpoint. Office2003 generated a new textbox and the style of the text was the same as in Excel. Now my code fails with Office2010 and I get the following message: runtime error -2147188160 (80048240) Shapes.PasteSpecial : Invalid request. Clipboard is empty or contains data which may not be pasted here. The clipboard is definitly not empty. The code is the

How can I get the SlideIndex of a visible Slide in Powerpoint when SelectionType = ppSelectionNone

一笑奈何 提交于 2020-02-03 05:15:38
问题 I have some code that requires me to know what SlideIndex to operate on (e.g., where to insert a new slide, where to insert a ChartObject, etc.). About 99% of the time, I can successfully obtain the SlideIndex by: Dim w as Long 'slide index variable w = ActivePresentation.Windows(1).Selection.SlideRange(1).SlideIndex The other 0.1% of the time, when ActivePresentation.Windows(1).SelectionType = ppSelectionNone , it will fail, because (understandably) it can't obtain the SlideIndex of the

How can I get the SlideIndex of a visible Slide in Powerpoint when SelectionType = ppSelectionNone

◇◆丶佛笑我妖孽 提交于 2020-02-03 05:14:46
问题 I have some code that requires me to know what SlideIndex to operate on (e.g., where to insert a new slide, where to insert a ChartObject, etc.). About 99% of the time, I can successfully obtain the SlideIndex by: Dim w as Long 'slide index variable w = ActivePresentation.Windows(1).Selection.SlideRange(1).SlideIndex The other 0.1% of the time, when ActivePresentation.Windows(1).SelectionType = ppSelectionNone , it will fail, because (understandably) it can't obtain the SlideIndex of the

how to convert powerpoint note text to speech with vba

我只是一个虾纸丫 提交于 2020-01-25 21:00:28
问题 I want to write a VBA macro that converts the note text to speech using the native windows speech capability. Anyone done this before? Any tips how to start and proceed? In the end I will need to provide different EU languages for conversion. Thanks John. 回答1: Right, as mentioned above, add a reference in your project to Microsoft Speech Object Library. Then this function will set you on the right path: Function SpeakThis(myPhrase As String) Dim oSpeaker As New SpeechLib.SpVoice ' Set speech

ActiveX can't create object powerpont vba

99封情书 提交于 2020-01-25 20:28:12
问题 I am trying to copy 1st slide from the powerpoint and insert it at the end but I am getting ActiveX can't create object on the line ActivePresentation.Slides(1).Copy This is my full code and I've added the reference to microsoft powerpoint library as well Option Explicit Dim myFile, Fileselected As String, Path As String, objPPT As Object Dim activeSlide As PowerPoint.Slide Sub Generate_PPTs() Application.ScreenUpdating = False Set myFile = Application.FileDialog(msoFileDialogOpen) With

ActiveX can't create object powerpont vba

早过忘川 提交于 2020-01-25 20:27:25
问题 I am trying to copy 1st slide from the powerpoint and insert it at the end but I am getting ActiveX can't create object on the line ActivePresentation.Slides(1).Copy This is my full code and I've added the reference to microsoft powerpoint library as well Option Explicit Dim myFile, Fileselected As String, Path As String, objPPT As Object Dim activeSlide As PowerPoint.Slide Sub Generate_PPTs() Application.ScreenUpdating = False Set myFile = Application.FileDialog(msoFileDialogOpen) With

Renaming object in PPT using VBA

…衆ロ難τιáo~ 提交于 2020-01-17 05:38:07
问题 I am currently trying to do a replace all on the object name in PowerPoint. Normally each content object is named Content Placeholder #, I have already named each object something like "PptBobChart1, PptBobScatter1", and now I need to do a replace all to change each of the object names into "PptTomChart1, PptTomScatter1". I know I can go into the selection pane one at a time to manually change it, but is there a way to do the whole thing in VBA? 回答1: You could try something like: Sub

VBA code works in debug mode but fails to run in whole

走远了吗. 提交于 2020-01-17 05:15:30
问题 Sub Export_as_PDF() Dim fil As Variant Dim strfile As String Dim PPApp As PowerPoint.Application Dim PPSlide As PowerPoint.Slide Dim SlideCount As Long Dim ws As Worksheet Dim Wb As Workbook Set PPApp = New PowerPoint.Application PPApp.Presentations.Add ' Slide 1 PPApp.ActivePresentation.Slides.Add PPApp.ActivePresentation.Slides.Count + 1,ppLayoutBlank Set PPSlide = PPApp.ActivePresentation.Slides (PPApp.ActivePresentation.Slides.Count) PPApp.ActiveWindow.View.GotoSlide PPApp

Unable to Add OLEObject In PowerPoint When Cell is in Edit Mode in Seperate Excel Window

落花浮王杯 提交于 2020-01-16 05:02:10
问题 First, open a new PowerPoint and Excel Document, then click on the first(or any) cell in the Excel document until the text cursor is visible, switch back to PowerPoint and run the following VBA code(Assuming you have at least one blank slide already present): ActivePresentation.slides(1).Shapes.AddOLEObject 30, 30, 100, 100, "Excel.Sheet" I receive the following error(on multiple systems): -2147467259 Method 'AddOLEObject' of object 'Shapes' failed If you close the separate Excel window, the