Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ActiveX text box control Powerpoint - pass variable in VBA 1

Status
Not open for further replies.

remeng

Technical User
Jul 27, 2006
504
0
16
US
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
 
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,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
The if may always evaluate to FALSE as written.

Text compared to a number?
 
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
 
If I use slide1.min_batch.[highlight #EF2929] [/highlight] text I get the error.
 
In VBA IDE, when you type:[tt]
slide1.[/tt]
do you get the intelisense that gives you a list of available controls?

And if so, after you choose:[tt]
slide1.min_batch.[/tt]
do you get another intelisense giving you the list of available properties and methoud to choose from?

Something that looks like this:
inteli_qfqbbm.png



---- Andy

There is a great need for a sarcasm font.
 
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

 
I’d do [tt]Slides(1)... Slides(2)...[/tt]

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Skip said:
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
 
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
 
>I can't figure out how to get access to an ActiveX control using it.

Something like

Code:
[blue]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[/blue]
 
Yeah,

.name
.sildeindex

Or any other properties of the slide is easy.

Have you figured out how to work with the ActiveX textbox?
 
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
 
>Have you figured out how to work with the ActiveX textbox?

Ah … in which case … erm :

Code:
[blue]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[/blue]
 
strongm said:
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top