Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-22-2015, 02:00 PM
JMer JMer is offline User form Help Windows 7 64bit User form Help Office 2010 64bit
Novice
User form Help
 
Join Date: Jul 2015
Posts: 6
JMer is on a distinguished road
Default User form Help

I have created a UserForm so that I can search my powerpoint slide during the presentation. I am trying to figure out how to code the command button "Next" on the userform to take me to the next time the searched word is found in the presentation. The code I am currently using is
Code:
Private Sub FCnext_Click()
If TextBox1 = True Then
  If Me.TextBox1.Text <> "" Then
    SlideShowWindows(1).View.GotoSlide (osld.SlideIndex)
  End If
End If
End Sub
 
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Dim osld As Slide
Dim oshp As Shape
Dim b_found As Boolean
If KeyCode = 13 Then 'ENTER PRESSED
  If Me.TextBox1.Text <> "" Then
    For Each osld In ActivePresentation.Slides
      For Each oshp In osld.Shapes
        If oshp.HasTextFrame Then
          If oshp.TextFrame.HasText Then
            If InStr(UCase(oshp.TextFrame.TextRange), UCase(Me.TextBox1.Text)) > 0 Then
              SlideShowWindows(1).View.GotoSlide (osld.SlideIndex)
              Me.TextBox1.Text = ""
              b_found = True
              Exit For
            End If
          End If
        End If
      Next oshp
      If b_found = True Then Exit For
    Next osld
  End If
  If b_found = False Then MsgBox "Not found"
End If
End Sub
The second part is the search part for the text box inside of my user form, it works correctly, the trouble I am having is getting the command button to do the search again and take me to the next slide.

Thank you for any help.

Last edited by macropod; 07-22-2015 at 06:32 PM. Reason: Added code tags & formatting
Reply With Quote
  #2  
Old 07-23-2015, 02:28 AM
JohnWilson JohnWilson is offline User form Help Windows 7 64bit User form Help Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

Maybe this (you could easily add the keydown sub but it's not needed. Might need a little edit to get the all found correct.

Code:
Dim SldINX As Long
Private Sub UserForm_Initialize()
Me.FCnext.Caption = "Find"
End Sub
Private Sub FCnext_Click()
If SldINX = 0 Then SldINX = 1
Me.FCnext.Caption = "Next"
Call searchSlide(SldINX)
End Sub
Sub searchSlide(fromSld As Long)
Dim oshp As Shape
Dim osld As Slide
Dim Counter As Long
Dim b_found As Boolean
If SldINX > ActivePresentation.Slides.Count Then
MsgBox "Done"
Unload UserForm1
Exit Sub
End If
For Counter = fromSld To ActivePresentation.Slides.Count
Set osld = ActivePresentation.Slides(Counter)
For Each oshp In osld.Shapes
        If oshp.HasTextFrame Then
          If oshp.TextFrame.HasText Then
            If InStr(UCase(oshp.TextFrame.TextRange), UCase(Me.TextBox1.Text)) > 0 Then
              SlideShowWindows(1).View.GotoSlide (osld.SlideIndex)
              b_found = True
               SldINX = Counter + 1
               Exit For
            End If
          End If
        End If
      Next oshp
      If b_found Then Exit For
    Next Counter
  If b_found = False Then
  SlideShowWindows(1).View.GotoSlide (ActivePresentation.Slides.Count)
   MsgBox "Not Found"
  Me.TextBox1.Text = ""
  SldINX = 1
  Unload UserForm1
  End If
End Sub
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials

Last edited by JohnWilson; 07-23-2015 at 04:30 AM.
Reply With Quote
  #3  
Old 07-23-2015, 09:07 AM
JMer JMer is offline User form Help Windows 7 64bit User form Help Office 2010 64bit
Novice
User form Help
 
Join Date: Jul 2015
Posts: 6
JMer is on a distinguished road
Default Awesome!

Thank you so much. That worked perfectly, Now that it is working tho it showed me that I need to either highlight the found text or put a box around it so that it stands out on the slide. This presentation is very heavy with information so search thru the slides it pulls up can be a job in itself. Is this easily added to the code?
Reply With Quote
  #4  
Old 07-24-2015, 05:41 AM
JohnWilson JohnWilson is offline User form Help Windows 7 64bit User form Help Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

This is straight off the top of my head but it might work

Code:
Dim SldINX As Long
Private Sub UserForm_Initialize()
Me.FCnext.Caption = "Find"
End Sub
Private Sub FCnext_Click()
If SldINX = 0 Then SldINX = 1
Me.FCnext.Caption = "Next"
Call searchSlide(SldINX)
End Sub
Sub searchSlide(fromSld As Long)
Dim oshp As Shape
Dim osld As Slide
Dim Counter As Long
Dim b_found As Boolean
Dim oTxtTemp As TextRange
Dim strFind As String
On Error Resume Next
For Each osld In ActivePresentation.Slides
osld.Shapes("redBox").Delete
Next osld
If SldINX > ActivePresentation.Slides.Count Then
MsgBox "Done"
Unload UserForm1
Exit Sub
End If
strFind = Me.TextBox1.Text
For Counter = fromSld To ActivePresentation.Slides.Count
Set osld = ActivePresentation.Slides(Counter)
For Each oshp In osld.Shapes
        If oshp.HasTextFrame Then
          If oshp.TextFrame.HasText Then
            Set oTxtTemp = oshp.TextFrame.TextRange.Find(strFind, , False)
            If Not oTxtTemp Is Nothing Then
              SlideShowWindows(1).View.GotoSlide (osld.SlideIndex)
              With osld.Shapes.AddShape(msoShapeRectangle, oTxtTemp.BoundLeft, oTxtTemp.BoundTop, oTxtTemp.BoundWidth, oTxtTemp.BoundHeight)
              .Fill.Visible = False
              .Line.ForeColor.RGB = vbRed
              .Name = "redBox"
              End With
              b_found = True
               SldINX = Counter + 1
               Exit For
            End If
          End If
        End If
      Next oshp
      If b_found Then Exit For
    Next Counter
  If b_found = False Then
  SlideShowWindows(1).View.GotoSlide (ActivePresentation.Slides.Count)
   MsgBox "Not Found"
  Me.TextBox1.Text = ""
  SldINX = 1
  Unload UserForm1
  End If
End Sub
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #5  
Old 07-24-2015, 12:35 PM
JMer JMer is offline User form Help Windows 7 64bit User form Help Office 2010 64bit
Novice
User form Help
 
Join Date: Jul 2015
Posts: 6
JMer is on a distinguished road
Default Again, Perfect

Thank you so Much. You really made helped me out. Thank you the code works perfectly.
Reply With Quote
  #6  
Old 07-24-2015, 03:36 PM
JMer JMer is offline User form Help Windows 7 64bit User form Help Office 2010 64bit
Novice
User form Help
 
Join Date: Jul 2015
Posts: 6
JMer is on a distinguished road
Default

Mr Wilson maybe you could help me out again. This might be easier than my previous need, which i greatly appreciate your help.
I have 3 monitors that I am using set up in a pyramid 2 on bottom and a 55" display above. When I go to the slide show and run the userform they do not appear on the same screen. I tried to use the properties postion but when I center it it puts it in the middle of all 3 screens. I also tried the following code
Code:
 
Private Sub FastConnectSearch_Initialize()
Dim TopOffset As Integer 
    Dim LeftOffset As Integer 
     
    TopOffset = (Application.UsableHeight / 2) - (Me.Height / 2) 
    LeftOffset = (Application.UsableWidth / 2) - (Me.Width / 2) 
     
    Me.Top = Application.Top + TopOffset 
    Me.Left = Application.Left + LeftOffset 
     
End Sub
FastConnectSearch is the title of my userform. This however is putting it at the top left of the bottom screen. Is their away to assign the userform to open in the same screen as the show regardless of what screen it is on?
Reply With Quote
  #7  
Old 07-24-2015, 06:19 PM
JMer JMer is offline User form Help Windows 7 64bit User form Help Office 2010 64bit
Novice
User form Help
 
Join Date: Jul 2015
Posts: 6
JMer is on a distinguished road
Default Document

@johnwilson
I have added a skeleton of the presentation that I am working on. Please understand that for legal reasons I cannot post the document with all the proprietary content. But I figured it would give you a better idea of what I am attempting to accomplish.

The presentation is distributed as a Macro enabled show only and is used as basically a contact database with hundreds if not thousands of contacts and numbers and departments.

As you can vaguely see (due to me having to remove the smart boxes and quite a bit of content) I have placed labels that are coded to take me to slides in presentation when in the show view. The search button at the top, coded by you, works perfectly and the red box is perfect. The only other thing I could ask is for a bit of help on the label coding.

They work effectively enough but with the amount of information on each give slide the some labels are required to go to actual parts of a slide much like the search feature. I have been attempting to use your Redbox code modified to have a somewhat large, noticeable Red circle next the label information on the slide.

For example slide 7 has the words Zone 2 and Zone 3. The two labels on the home page take you to that slide from the code but I would like the Red circle to show and then disappear if that corresponding label is pushed.

I apologize for the continued request for help, I am attempting to make this presentation as user friendly as possible and have put in dozens of hours entering information and have just hit a wall. It doesn’t help that I am new to VBA coding and teaching myself as I go. Please any help would be greatly appreciated.
Attached Files
File Type: pptm File for Forum.pptm (215.5 KB, 12 views)

Last edited by JMer; 07-24-2015 at 06:22 PM. Reason: Removed info from presentation
Reply With Quote
Reply

Tags
userform, vba, vba powerpoint



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA to save word user form value to xml Rose roon Word VBA 25 06-23-2015 04:35 AM
User Form - Close Paragraphs SonyaEnz Word VBA 4 06-05-2015 06:16 AM
User form abdulgani Excel 0 12-15-2014 05:54 AM
User form Help User Form placasse47 Excel Programming 3 08-01-2012 05:57 AM
Controlling Style when a user pastes into a form Cris0205 Word 0 08-05-2010 04:33 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:37 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft