×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

ActiveX text box control Powerpoint - pass variable in VBA

ActiveX text box control Powerpoint - pass variable in VBA

ActiveX text box control Powerpoint - pass variable in VBA

(OP)
Hello,

I need to create a form in Powerpoint. I know it isn't ideal but that's what I have been asked to do.

I have created an ActiveX text box on slide 1. The control name is min_batch.

I have an ActiveX text box on slide 2. The control name is min1.

When I change min_batch on slide 1, I'd like to have min1 update automatically on slide 2. While in VBA I can capture the value in min_batch, it doesn't pass it to the min1 box.

What am I doing incorrectly?

CODE

Sub min_batch_Change()



If min_batch > 0 Then



Set min1 = min_batch
Set min2 = min_batch
Set min3 = min_batch
Set min4 = min_batch
Set min5 = min_batch
Set min6 = min_batch

Else

End If

End Sub 

Thanks,

Mike

RE: ActiveX text box control Powerpoint - pass variable in VBA

Be explicit.

slide2.min2.value = slide1.min_batch.value

RE: ActiveX text box control Powerpoint - pass variable in VBA

CODE

‘
If slide1.min_batch.Text > “0” Then


   slide2.min1.Text = slide1.min_batch.Text
   slide2.min2.Text = slide1.min_batch.Text
   slide2.min3.Text = slide1.min_batch.Text
   slide2.min4.Text = slide1.min_batch.Text
   slide2.min5.Text = slide1.min_batch.Text
   slide2.min6.Text = slide1.min_batch.Text

Else

End If 

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: ActiveX text box control Powerpoint - pass variable in VBA

The if may always evaluate to FALSE as written.

Text compared to a number?

RE: ActiveX text box control Powerpoint - pass variable in VBA

(OP)
Hi,

Thank you for the quick responses.

I am getting a error. "Method or data not found"

if I use the min_batch.text I get the correct value. If I use slide1.min_batch. text I get the error.

Is there a way to check the slide number?

Is there a way to name the slides so that if another one is added, the vba doesn't need to be updated?

What might be incorrect with the code too?

Thanks,

Mike

RE: ActiveX text box control Powerpoint - pass variable in VBA

If I use slide1.min_batch. text I get the error.

RE: ActiveX text box control Powerpoint - pass variable in VBA

In VBA IDE, when you type:
slide1.

do you get the intelisense that gives you a list of available controls?

And if so, after you choose:
slide1.min_batch.

do you get another intelisense giving you the list of available properties and methoud to choose from?

Something that looks like this:


---- Andy

There is a great need for a sarcasm font.

RE: ActiveX text box control Powerpoint - pass variable in VBA

The .SlideID property remains constant as slides are added, deleted or moved.

But it is not immediately apparent that you can directly work with this property to get access to a Control.

https://docs.microsoft.com/en-us/office/vba/api/po...

RE: ActiveX text box control Powerpoint - pass variable in VBA

(OP)
Hi Andy,

Got it. the slide 2 is actually Slide 271. Slide 1 is Slide 1...

I need to just watch what the slide name is.

Thanks,

Mike

RE: ActiveX text box control Powerpoint - pass variable in VBA

I’d do Slides(1)... Slides(2)...

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: ActiveX text box control Powerpoint - pass variable in VBA

Quote (Skip)

I’d do Slides(1)... Slides(2)...
Slides(1) etc returns a slide's CURRENT location in a presentation. Not so good if things move.

Whereas the .SlideID property is unique and unchanging when slides move, other slides are deleted etc.

But I can't figure out how to get access to an ActiveX control using it.

CODE -->

Public Sub WorkWithSlideID(Target As Long)
Dim MySlideID As Slide
Set MySlideID = Application.ActivePresentation.Slides.FindBySlideID(Target)
MySlideID.Select
End Sub 

RE: ActiveX text box control Powerpoint - pass variable in VBA

You can add control to custom master slide if it can be useful in your project. Powerpoint mixes master slide and slide data in a single view, so you can have one control visible on multiple slides. In VBE master slide module id displayed as blue icon in project explorer window.

combo

RE: ActiveX text box control Powerpoint - pass variable in VBA

>I can't figure out how to get access to an ActiveX control using it.

Something like

CODE

Public Function SlideById(Target As Long) As Slide
    Set SlideById = Application.ActivePresentation.Slides.FindBySlideID(Target)
End Function

Public Sub test()
    Dim ExampleID As Long
    ExampleID = Application.ActivePresentation.Slides(1).SlideID
    MsgBox SlideById(ExampleID).Name
End Sub 

RE: ActiveX text box control Powerpoint - pass variable in VBA

Yeah,

.name
.sildeindex

Or any other properties of the slide is easy.

Have you figured out how to work with the ActiveX textbox?

RE: ActiveX text box control Powerpoint - pass variable in VBA

(OP)
Here is the project code that works for reference. I still need to test and try and break the coding.

Resets all variables on slide 1 (inputs)

CODE

Private Sub reset_Click()

' entry values

Slide1.dev_freq.Text = ""

    Slide271.freq_dia.Text = Slide1.dev_freq.Text
    Slide278.freq_dia.Text = Slide1.dev_freq.Text
    Slide279.freq_dia.Text = Slide1.dev_freq.Text
    Slide280.freq_dia.Text = Slide1.dev_freq.Text
    Slide281.freq_dia.Text = Slide1.dev_freq.Text
    Slide282.freq_dia.Text = Slide1.dev_freq.Text

Slide1.frozen.Text = ""

    Slide271.frozen_period.Text = Slide1.frozen.Text
    Slide278.frozen_period.Text = Slide1.frozen.Text
    Slide279.frozen_period.Text = Slide1.frozen.Text
    Slide280.frozen_period.Text = Slide1.frozen.Text
    Slide281.frozen_period.Text = Slide1.frozen.Text
    Slide282.frozen_period.Text = Slide1.frozen.Text


Slide1.min_batch.Text = ""

    Slide271.min1.Text = Slide1.min_batch.Text
    Slide278.min2.Text = Slide1.min_batch.Text
    Slide279.min3.Text = Slide1.min_batch.Text
    Slide280.min4.Text = Slide1.min_batch.Text
    Slide281.min5.Text = Slide1.min_batch.Text
    Slide282.min6.Text = Slide1.min_batch.Text

Slide1.hu.Text = ""


    Slide278.hu.Text = Slide1.hu.Text
    Slide279.hu.Text = Slide1.hu.Text
    Slide281.hu.Text = Slide1.hu.Text
    Slide282.hu.Text = Slide1.hu.Text

'check boxes

Slide1.Returnable.Value = False
Slide1.disposable.Value = False

'radio buttons

Slide1.warehouse.Value = False
Slide1.plant.Value = False
Slide1.tct.Value = False
Slide1.three_pl.Value = False
Slide1.dap.Value = False
Slide1.fca.Value = False


End Sub 

passes variable from slide 1 to other slides

CODE

Private Sub dev_freq_Change()

If Slide1.dev_freq.Text > "" Then

    Slide271.freq_dia.Text = Slide1.dev_freq.Text
    Slide278.freq_dia.Text = Slide1.dev_freq.Text
    Slide279.freq_dia.Text = Slide1.dev_freq.Text
    Slide280.freq_dia.Text = Slide1.dev_freq.Text
    Slide281.freq_dia.Text = Slide1.dev_freq.Text
    Slide282.freq_dia.Text = Slide1.dev_freq.Text

End If

End Sub

Private Sub frozen_Change()

If Slide1.frozen.Text > "" Then

    Slide271.frozen_period.Text = Slide1.frozen.Text
    Slide278.frozen_period.Text = Slide1.frozen.Text
    Slide279.frozen_period.Text = Slide1.frozen.Text
    Slide280.frozen_period.Text = Slide1.frozen.Text
    Slide281.frozen_period.Text = Slide1.frozen.Text
    Slide282.frozen_period.Text = Slide1.frozen.Text

    
    
    
End If


End Sub

Private Sub hu_Change()

If Slide1.hu.Text > "" Then

    
    Slide278.hu.Text = Slide1.hu.Text
    Slide279.hu.Text = Slide1.hu.Text
    Slide281.hu.Text = Slide1.hu.Text
    Slide282.hu.Text = Slide1.hu.Text

End If


End Sub

Private Sub min_batch_Change()

If Slide1.min_batch.Text > "" Then

    Slide271.min1.Text = Slide1.min_batch.Text
    Slide278.min2.Text = Slide1.min_batch.Text
    Slide279.min3.Text = Slide1.min_batch.Text
    Slide280.min4.Text = Slide1.min_batch.Text
    Slide281.min5.Text = Slide1.min_batch.Text
    Slide282.min6.Text = Slide1.min_batch.Text

End If

End Sub 

After a trigger, the presentation changes to another slide

CODE

Private Sub warehouse_Click()

If Returnable And warehouse And dap = True Then

 ActivePresentation.SlideShowWindow.View.GotoSlide 3
 
        
        
Else
        
        If Returnable And plant = True Then
        
        ActivePresentation.SlideShowWindow.View.GotoSlide 7
        

    
    
Else

        If disposable And warehouse = True Then

        ActivePresentation.SlideShowWindow.View.GotoSlide 2



Else

        If disposable And plant = True Then

        ActivePresentation.SlideShowWindow.View.GotoSlide 6


        End If

    End If

End If

End If

End Sub 

RE: ActiveX text box control Powerpoint - pass variable in VBA

>Have you figured out how to work with the ActiveX textbox?

Ah … in which case … erm :

CODE

Public Function GetControl(MySlide As Slide, strName As String) As Object
    Dim thing As Shape
    For Each thing In MySlide.Shapes
        If thing.Type = msoOLEControlObject And LCase(thing.Name) = LCase(strName) Then
            Set GetControl = thing.OLEFormat.Object
            Exit For
        End If
    Next
End Function 

RE: ActiveX text box control Powerpoint - pass variable in VBA

Quote (strongm)

Ah … in which case … erm :

Ugh.
Yeah, I was wondering if .Shapes would be part of the solution.

It would have taken me a long time to stumble upon "Set GetControl = thing.OLEFormat.Object"

Well done.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close