Clarification of VBA copy to clipboard

  • Thread starter Victor and TJ Friedmann
  • Start date
V

Victor and TJ Friedmann

My objective is this:

Click on an object that activates a macro to do the following:

Copies all text from the slide onto the clipboard, activates notepad, copies
clipboard contents into notepad and then activates calculator.

I can activate the notepad and calculator using Shell command but have been
unable to copy, let alone paste, the text onto the clipboard.

Any help is welcome.

Here is a sample of one effort to copy text:

Sub servings()

ActiveWindow.Selection.SlideRange.Shapes.TextFrame.TextRange
ActiveWindow.Selection.Copy






End Sub



Vic
 
D

David Marcovitz

A couple of more questions...

Are you trying to run this in Slide Show view or Normal/Edit view? "Click on
an object" implies to me that you are thinking of Slide Show view. In that
case, you can't do anything that involves selecting.

Are you trying to get the text from the object that is clicked or all the
text on the entire slide?

--David

My objective is this:

Click on an object that activates a macro to do the following:

Copies all text from the slide onto the clipboard, activates notepad, copies
clipboard contents into notepad and then activates calculator.

I can activate the notepad and calculator using Shell command but have been
unable to copy, let alone paste, the text onto the clipboard.

Any help is welcome.

Here is a sample of one effort to copy text:

Sub servings()

ActiveWindow.Selection.SlideRange.Shapes.TextFrame.TextRange
ActiveWindow.Selection.Copy






End Sub



Vic

--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
 
V

Victor and TJ Friedmann

David, thanks for your interest. I am trying to do this in Slide Show where
the client clicks on an object and the macro copies the text from all text
frames in the slide onto the clipboard and then pastes them in notepad. Can
this be done? How?

Vic
 
D

David Marcovitz

Something likes this collects all the text into a variable:

Sub CopyAll()
Dim oShp As Shape
Dim oShpForSaving As Shape
Dim txtSavedText As String
txtSavedText = ""
For Each oShp In ActivePresentation.SlideShowWindow.View.Slide.Shapes
If oShp.HasTextFrame Then
txtSavedText = txtSavedText & oShp.TextFrame.TextRange.Text
End If
Next oShp
MsgBox txtSavedText
End Sub

But I'm not sure you can copy and paste it from Slide Show View.

--David

David, thanks for your interest. I am trying to do this in Slide Show where
the client clicks on an object and the macro copies the text from all text
frames in the slide onto the clipboard and then pastes them in notepad. Can
this be done? How?

Vic

--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
 
V

Victor and TJ Friedmann

David,

This macro works but it copies the next slide rather than the current slide.
Any ideas?

Vic
 
D

David Marcovitz

I hate to say that that is impossible, but ... that is impossible.
ActivePresentation.SlideShowWindow.View.Slide refers to the current slide.
This will get the text from whatever slide you are on, not the next slide.
--David

David,

This macro works but it copies the next slide rather than the current slide.
Any ideas?

Vic

--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
 
V

Victor and TJ Friedmann

OK, David. I am going to try once again. but last I cecked it pasted the
contents of the next slide. I am going to double check and let you know. I
agree with you, I don't see how this can be.

Vic
 
J

John Wilson

Agree with David

But why not write the text direct to a text file instead of copying?

This is just aircode but should get you going

Write to a text file in same folder as presentation NB Presentation must be
saved!

Sub CopyAll()
Dim oShp As Shape
Dim osld As Slide
Dim intFileNum As Integer
Dim strFileName As String
Dim i As Integer
intFileNum = FreeFile()
strFileName = ActivePresentation.Path & "\MyText.txt"
Set osld = SlideShowWindows(1).View.Slide
Dim txtSavedText As String
txtSavedText = ""
For Each oShp In osld.Shapes
If oShp.HasTextFrame Then
If oShp.TextFrame.HasText Then
For i = 1 To oShp.TextFrame.TextRange.Paragraphs.Count
txtSavedText = txtSavedText & _
oShp.TextFrame.TextRange.Paragraphs(i).Text & vbCrLf
Next
Open strFileName For Output As intFileNum
Print #intFileNum, txtSavedText
Close #intFileNum
End If
End If
Next oShp
End Sub
--
john ATSIGN PPTAlchemy.co.uk
Custom vba coding and PPT Makeovers
Free PPT Hints, Tips and Tutorials
http://www.pptalchemy.co.uk/powerpoint_hints_and_tips_tutorials.html
PPTLive Atlanta 2009
 
V

Victor and TJ Friedmann

David, I hate to saddle you with this problem because you have been so
helpful, BUT the impossible did happen.

Here is what I did. I assigned your macro to a shape., went into slide show,
clicked on the shape. Then, just to be sure, I opened a brand new
presentation and pasted the contents of the clipboard. What it pasted was an
entire slide but not the current one, it was several slides away, but it
always copies the same one--graphics and text, not just the text.

Vic
 
D

David Marcovitz

Well, that makes sense now. My code didn't do the copy part. It just put up
a message box with all the text. I'm not sure you can copy in Slide Show
View (but I could be wrong). That is, it did half the job: the part that
assembles all the text in one place for you.
--David

David, I hate to saddle you with this problem because you have been so
helpful, BUT the impossible did happen.

Here is what I did. I assigned your macro to a shape., went into slide show,
clicked on the shape. Then, just to be sure, I opened a brand new
presentation and pasted the contents of the clipboard. What it pasted was an
entire slide but not the current one, it was several slides away, but it
always copies the same one--graphics and text, not just the text.

Vic

--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
 
V

Victor and TJ Friedmann

Shouldn't because I have the show in kiosk mode and the slide advance
trigger is way down the page. I'll look at it some more as I go along.
Thanks for all your help and will keep you posted.

Vic
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top