Solved

Text box values

Posted on 2001-06-06
14
194 Views
Last Modified: 2012-06-21
Hi Folks,

I've written code to call out from Powerpoint to WinSock32.dll to run a ping command. I've stuck the code, as a macro, behind a text box and supplied the IP address and it's worked fine.

I.E. MyPingCommand(strIPaddress,ECHO)

Forget the second agrument it doesn't matter.

ALL I want to do is to reference the value in the textbox I'm clicking and pass that value in as the IP Address. How do I do it?

I'm feeling very generous, so there's 200 points on offer!
0
Comment
Question by:TimE
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
14 Comments
 
LVL 6

Expert Comment

by:blakeh1
ID: 6160381
You can use the following, just changes names and indexes as needed (Note this will work only if you added it from the Control Toolbox toobar, not the Forms toolbar)    


Dim txt As Object
    Dim sText As String
    Set txt = Worksheets(1).Shapes("TextBox1").OLEFormat.Object
    sText = txt.Object.Value
0
 
LVL 13

Expert Comment

by:cri
ID: 6161396
blakeh1, its Powerpoint time...
0
 
LVL 13

Expert Comment

by:cri
ID: 6161407
TimE, I played around a bit, but did not find yet a solution worth to be posted.

Additionally, I have questions:

a) Is a solution which is 'hardcoded' for each textbox acceptable ? >> Use ActionSettings

b) Does it have to be a general solution ? >> No clue, Powerpoint/VBA is much weaker than Excel/VBA or even Word/VBA, not to speak about my own practice of it.

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:TimE
ID: 6162972
Yeah, basically it does have to be PowerPoint, unless it really can't be done.

To give you some more info. The PowerPoint Slides are network diagrams and the text boxs are the IP addresses associated with the network components. My plan is (was?) to allow you to click the IP address in the Slide and do a ping test, thus saving getting up a DOS prompt and typing "ping www.xxx.yyy.zzz"
0
 

Author Comment

by:TimE
ID: 6162982
Oh, yeah, I guess I could Hardcode it, I mean I've already proved that works no problems. But a nice generic Sub with the agrument passed in would be so much sweeter.
0
 

Author Comment

by:TimE
ID: 6162987
Oh, yeah, I guess I could Hardcode it, I mean I've already proved that works no problems. But a nice generic Sub with the agrument passed in would be so much sweeter.
0
 
LVL 13

Expert Comment

by:cri
ID: 6163339
What about a half-automated solution ? I mean a macro assisted generation of the hardcoded instructions ?
0
 

Author Comment

by:TimE
ID: 6163631
OK, sounds better. But you've lost me a bit. What exactly R U suggesting?
0
 
LVL 13

Expert Comment

by:cri
ID: 6164606
Something like this:

Option Explicit 'to prevent typos

Sub CodeGenerator()
  'Writes a code snippet for each textbox on slide one
 
  Dim sPath As String, myShape As Shape
 
  sPath = "c:\temp\PPT_VBA.bas" '<< Adapt as required
  Open sPath For Output As #1
  With ActivePresentation.Slides(1) '<< Adapt or make additional loop
    For Each myShape In .Shapes
      With myShape
        If .TextFrame.HasText = True Then
          'ATTENTION: Starting point only, adapt where necessary
          Print #1, "With Shapes(""" & .Name & """).ActionSettings(ppMouseClick) "
          Print #1, "  .Action = ppActionRunMacro"
          Print #1, "  .Run = " & .TextFrame.TextRange.Text
          Print #1, "  .AnimateAction = True"
          Print #1, "End With"
          Print #1,
        End If
      End With
    Next myShape
  End With
  Close #1
  MsgBox sPath & "  finished !"
End Sub
0
 
LVL 13

Expert Comment

by:cri
ID: 6166891
Forget previous post, this solution here starts to get sensible:


Option Explicit 'to prevent typos

Sub PrimeTextboxFrameActionSettings()
 'Attention: Clicking _text_ of textframe has no effect (yet) as it
  '          has its own action setting !
 
 Dim myShape As Shape
 
 With ActivePresentation.Slides(1) '<< Adapt or make additional loop
   For Each myShape In .Shapes
     With myShape
       If .TextFrame.HasText = True Then
         With .ActionSettings(ppMouseClick)
          .Action = ppActionRunMacro
          .Run = "PlaceHolder" 'Shape is passed as argument by PPT
         End With
       End If
     End With
   Next myShape
 End With
 MsgBox "All textbox FRAMES are primed !"
End Sub

Sub PlaceHolder(myClickedShape As Shape)
  MsgBox myClickedShape.Name & " contains " & myClickedShape.TextFrame.TextRange.Text
End Sub
0
 
LVL 13

Accepted Solution

by:
cri earned 200 total points
ID: 6178869
Ping...
0
 
LVL 13

Expert Comment

by:cri
ID: 6194218
Ping...

Please do not forget this question.
0
 

Author Comment

by:TimE
ID: 6205260
Sorry I haven't got back sooner, I was taking a few days vacation.

Mighty fine answer! I've added some constraints so only textboxes containing IP address actually get primed and stuck that loop to go through all slides.

Thanks again, enjoy your points!!
0
 
LVL 13

Expert Comment

by:cri
ID: 6207049
ThAnk you. Hope you did enjoy your vacation. Did not want to pester you, but as approx. 40% of the questions are abandoned I wanted to be sure this solution does not get lost, it took quite a while to figure out that Powerpoint passes the textbox name as argument...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question