Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7673747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:35:00+00:00 2026-05-31T16:35:00+00:00

I successfully used this code within a powerpoint odule, but when I move it

  • 0

I successfully used this code within a powerpoint odule, but when I move it inside my excel module it gives me several problems. I embedded the Powerpoint application on sheet 1 of Excel. The goal is to generate the powerpoint from excel and replace the company name whenever it appears on a powerpoint slide with the new company name from an excel range.
I get error 429 ActiveX component cant create object at “For Each osld In ActivePresentation.Slides. Is my Powerpoint presentation not active? Any help would be appreciated. Using excel/Powerpoint 2010.

Sub changeme(sFindMe As String, sSwapme As String) 
Dim osld As Slide 
Dim oshp As Shape 
Dim otemp As TextRange 
Dim otext As TextRange 
Dim Inewstart As Integer 



For Each osld In ActivePresentation.Slides 
For Each oshp In osld.Shapes 
    If oshp.HasTextFrame Then 
        If oshp.TextFrame.HasText Then 

            Set otext = oshp.TextFrame.TextRange 
            Set otemp = otext.Replace(sFindMe, sSwapme, , msoFalse, msoFalse) 
            Do While Not otemp Is Nothing 
                Inewstart = otemp.Start + otemp.Length 
                Set otemp = otext.Replace(sFindMe, sSwapme, Inewstart, msoFalse, msoFalse) 
            Loop 

        End If 
    End If 

Next oshp 
Next osld 
End Sub 
 '-------------------------------------------------------------------------
Sub swap() 
Dim sFindMe As String 
Dim sSwapme As String 
Dim ppApp As PowerPoint.Application 
Dim ppPreso As PowerPoint.Presentation 

 'Start Powerpoint

 'Look for existing instance
On Error Resume Next 
Set ppApp = GetObject(, "PowerPoint.Application") 
On Error Goto 0 

 'Create new instance if no instance exists
Set ppApp = CreateObject("Powerpoint.Application") 



 'Open Template in word
With Sheets("Sheet1").Shapes("Object 1").OLEFormat.Verb(Verb:=xlVerbOpen) 
End With 
 'Make it visible
ppApp.Visible = True 



sFindMe = "Name To Find" 
 'change this to suit
sSwapme = "New Name" 
Call changeme(sFindMe, sSwapme) 
 'sFindMe = "<find2>"
 'sSwapme = ActivePresentation.Slides(1).Shapes(2).TextFrame.TextRange
 'Call changeme(sFindMe, sSwapme)
End Sub 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:35:01+00:00Added an answer on May 31, 2026 at 4:35 pm

    ActivePresentation is a Powerpoint Object. It doesn’t mean anything to Excel. When you open a presentation you have to set a connection to it for Excel to relate with it. I would suggest using the below code. Also I have used Late Binding so you don’t need to add any reference to MS Powerpoint from Excel.

    LOGIC:

    • Save the embedded PPT to a temp folder
    • Open the file in Excel and then make the changes

    TRIED AND TESTED

    Private Declare Function GetTempPath Lib "kernel32" _
    Alias "GetTempPathA" (ByVal nBufferLength As Long, _
    ByVal lpBuffer As String) As Long
    
    Dim ppApp As Object, ppPreso As Object, ppPresTemp As Object
    
    Sub swap()
        Dim sFindMe As String, sSwapme As String, FlName As String
        Dim objOLE As OLEObject
        Dim sh As Shape
    
        '~~> Decide on a temporary file name which will be saved in the
        '~~> users temporary folder. You might want to change the extention 
        '~~> from pptx to ppt if you are using earlier versions of MS Office
        FlName = GetTempDirectory & "\Temp.pptx"
    
        Set sh = Sheets("Sheet1").Shapes("Object 1")
    
        sh.OLEFormat.Activate
    
        Set objOLE = sh.OLEFormat.Object
    
        Set ppPresTemp = objOLE.Object
    
        '~~> Save the file to the relevant temp folder
        ppPresTemp.SaveAs Filename:=FlName
    
        '~~> Close the temp presentation that opened
        ppPresTemp.Close
    
        '~~> Establish an Powerpoint application object
        On Error Resume Next
        Set ppApp = GetObject(, "PowerPoint.Application")
    
        If Err.Number <> 0 Then
            Set ppApp = CreateObject("PowerPoint.Application")
        End If
        Err.Clear
        On Error GoTo 0
    
        ppApp.Visible = True
    
        Set ppPreso = ppApp.Presentations.Open(Filename:=FlName)
    
        sFindMe = "Name To Find"
        sSwapme = "New Name"
    
        changeme sFindMe, sSwapme
    
    
        '~~> In the end Clean Up (Delete the temp file saved in the temp directory)
        'Kill FlName
    End Sub
    
    Sub changeme(sFindMe As String, sSwapme As String)
        Dim osld As Object, oshp As Object
        Dim otemp As TextRange, otext As TextRange
        Dim Inewstart As Integer
    
        For Each osld In ppPreso.Slides
            For Each oshp In osld.Shapes
                If oshp.HasTextFrame Then
                    If oshp.TextFrame.HasText Then
                        Set otext = oshp.TextFrame.TextRange
    
                        Set otemp = otext.Replace(sFindMe, sSwapme, , _
                        msoFalse, msoFalse)
    
                        Do While Not otemp Is Nothing
                            Inewstart = otemp.Start + otemp.Length
                            Set otemp = otext.Replace(sFindMe, sSwapme, _
                            Inewstart, msoFalse, msoFalse)
                        Loop
                    End If
                End If
            Next oshp
        Next osld
    End Sub
    
    '~~> Function to get the user's temp directory
    Function GetTempDirectory() As String
       Dim buffer As String
       Dim bufferLen As Long
       buffer = Space$(256)
       bufferLen = GetTempPath(Len(buffer), buffer)
       If bufferLen > 0 And bufferLen < 256 Then
          buffer = Left$(buffer, bufferLen)
       End If
       If InStr(buffer, Chr$(0)) <> 0 Then
          GetTempDirectory = Left$(buffer, InStr(buffer, Chr$(0)) - 1)
       Else
          GetTempDirectory = buffer
       End If
    End Function
    

    Hope this helps 🙂

    Sid

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I successfully have used this code snippet before, but with the file pointing to
On a Vista dev machine I used this code successfully to change user Administrator
Successfully used jquery-infinite-carousel in the past but for my current project I need it
I have successfully used the Excel and Word addin templates in Visual studio 2008
I used this library to make API requests and got the access tokens successfully.
I've successfully used the Windows SendMessage method to help me do various things in
Has anyone successfully used Tokyo Cabinet / Tokyo Tyrant with large datasets? I am
I wrote a device controller (rs232) and it is being used successfully, however users
What various methods and technologies have you used to successfully address scalability and performance
I've successfully compiled my library on Linux and Mac and used it with Java

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.