#1
|
|||
|
|||
Need Macro to Copy Notes from one PPT to another
I need a macro to copy the notes from one PowerPoint to another PowerPoint.
The notes contain multiple paragraphs. Is there an easy way to do this? Thanks! |
#2
|
|||
|
|||
If the notes are just plain text (no formatting) then you can adapt the code for pictures.
The notes are normally in Shapes(2) of the notes page. If for some reason theya re not it may crash. Sub switchNotes() Dim oTarget As Presentation Dim oSource As Presentation Dim i As Integer On Error Resume Next 'NOTE use the names of your own presentations Set oTarget = Presentations("Image1.pptx") Set oSource = Presentations("Image2.pptx") For i = 1 To oSource.Slides.Count oTarget.Slides(i).NotesPage.Shapes(2) _ .TextFrame.TextRange = _ oSource.Slides(i).NotesPage.Shapes(2) _ .TextFrame.TextRange Next i End Sub |
#3
|
|||
|
|||
Worked -- Many thanks!
This worked perfectly! Thanks!
|
#4
|
|||
|
|||
Hi (several years later) - this code worked perfectly for me as well, but is it possible to modify the code to keep the source formatting of the presentation notes when moving over to the new presentation? I tried the following code, but it doesn't work very well (doesn't keep the font sizes after slide 1, completely breaks after slide 8). Is there a better way to do this?
Sub switchNotes() Dim oTarget As Presentation Dim oSource As Presentation Dim i As Integer On Error Resume Next Set oTarget = Presentations("TEST2.pptx") Set oSource = Presentations("TEST1.pptx") For i = 1 To oSource.Slides.Count oSource.Slides(i).NotesPage.Shapes(2) _ .TextFrame.TextRange.Copy oTarget.Slides(i).NotesPage.Shapes(2) _ .TextFrame.TextRange.PasteSpecial (ppPasteRTF) Next i End Sub Thanks! |
#5
|
|||
|
|||
Hey Alex311, it looks like the only issue was using TextRange.PasteSpecial (ppPasteRTF)... I used the regular paste and it worked like a charm.
Here's my updated version (tested and working flawlessly) Sub switchNotes() Dim oTarget As Presentation Dim oSource As Presentation Dim i As Integer On Error Resume Next Set oTarget = Presentations("target.pptx") Set oSource = Presentations("source.pptx") For i = 1 To oSource.Slides.Count oSource.Slides(i).NotesPage.Shapes(2) _ .TextFrame.TextRange.Copy oTarget.Slides(i).NotesPage.Shapes(2) _ .TextFrame.TextRange.Paste Next i End Sub Hoping it can help you and others as well. |
#6
|
|||
|
|||
Improving the script
Hi all.
After using this a little, I've made a few adjustments. - Added a few comments in the start of the script to tell clearly how to use it. - Commented out the 'On Error Resume Next', as it might hide a failure (I'd rather know when this is not working and debug WHY or WHERE it's not working). - Added (commented out) a MsgBox indicating the slide # so you can tell where something failed (use only if debugging). - Added an additional verification forcing a custom error in case the source and target presentations' slide count do not match. If for a reason you know those will not match, you may need to comment it out. Code:
Sub switchNotes() ' Target and Source files should be open ' oSource and oTarget should be filled with filename (no path) ' use with 'call switchNotes()' ' 'On Error Resume Next' commented out to spot failed process ' MsgBox used for debug purposes when needed Dim oTarget As Presentation Dim oSource As Presentation Dim i As Integer 'On Error Resume Next Set oSource = Presentations("mySource.pptx") Set oTarget = Presentations("myTarget.pptx") If oSource.Slides.Count <> oTarget.Slides.Count Then Err.Raise -10000000 For i = 1 To oSource.Slides.Count 'MsgBox ("diapo " & i) oSource.Slides(i).NotesPage.Shapes(2).TextFrame.TextRange.Copy oTarget.Slides(i).NotesPage.Shapes(2).TextFrame.TextRange.Paste Next i End Sub Hope it helps |
#7
|
|||
|
|||
Hello, newbie here, I was wondering how i can use the above script in PowerPoint?
|
#8
|
|||
|
|||
Hi Vagodspeed.
If you want to use this script, you should be a bit familiar with using VBA scripts and the scripting interface in Office. If you are not familiar with it, there's more chance of breaking things The latest version of the script as I posted it is meant to be added as a module in a macro-enabled PPTM file. Then, additionally you need to open the 2 files where you have the source notes to be copied and the target presentation where the notes are meant to be copied to. You have to update these lines in the code with the actual filenames: Set oSource = Presentations("mySource.pptx") Set oTarget = Presentations("myTarget.pptx") Once all is open and code updated, you need to go to the scripting interface and call the script from the immediate window as I explain in the comments using 'call switchNotes()' (without the quotes). Good luck |
#9
|
|||
|
|||
Thank you for the swift reply!
I will need to read more about VBA scripting then, before trying anything else. Do you happen to have any recommendations for any resources for doing so? |
#10
|
|||
|
|||
it's been really long since I started with this, and I was coming from already knowing different programming languages.
I'd suggest googling for 'VBA tutorial' and quickly check a few to see which one suits better your existing knowledge. Microsoft has it's own documentation but it might be a bit too Microsofty You can look for generals on VB in W3Schools and there's the VBA for dummies (VBA For Dummies, 5th Edition | Wiley) from Wiley... all the 'for Dummies' books are great for starting with anything. Don't look for Powerpoint specific scripting, because you don't really do much scripting in Powerpoint in general... you'll find a lot more about VBA for Excel and Access, plus some for Word... You only need to understand the basics (structures, variables, conditionals) and object oriented programming basics (such as object, properties, methods). In the end, you are not going to do this from scratch, just make sure you understand the piece of code you have in front and that you can edit it to fir your needs. Even in the totally worst case, the code already works... if you make backup copies, you can use trial and error and see how it goes |
#11
|
|||
|
|||
Thanks a lot for your effort here! I will try your suggestions.
|
#12
|
|||
|
|||
Hey, I've uploaded a slightly customized version of the script already inserted in a macro-enabled Powerpoint file (pptm). Feel free to use it.
Here's the actual script I'm using: Code:
Sub switchNotes(mySource As String, myTarget As String) ' Target and Source files should be open ' oSource and oTarget should be filled with filename (no path) // now passed via arguments ' call switchNotes("SOURCE NOTES","TARGET contains localized graphics") ' source means source notes. ' use with 'call switchNotes()' ' 'On Error Resume Next' commented out to spot failed process ' MsgBox used for debug purposes when needed Dim oTarget As Presentation Dim oSource As Presentation Dim i As Integer 'On Error Resume Next Set oSource = Presentations(mySource) Set oTarget = Presentations(myTarget) If oSource.Slides.Count <> oTarget.Slides.Count Then Err.Raise -10000000 For i = 1 To oSource.Slides.Count 'MsgBox ("diapo " & i) oSource.Slides(i).NotesPage.Shapes(2).TextFrame.TextRange.Copy oTarget.Slides(i).NotesPage.Shapes(2).TextFrame.TextRange.Paste Next i End Sub - The source, where you already have the notes. - The target, where you want the notes copied over. Take note of the filename of those files, let's say the source is called "myPowerpointFile.pptx" and the target is called "myBlankpowerpointFile.pptx". So now you have the 3 files open. While viewing the script file ("speaker notes copy script.pptm"), hit alt+F11 and it will open the scripting interface. Check if you have the "Immediate" pane open. If it's not, go to View > Immediate Window, so you open it. While on the Immediate Window, type: Code:
call switchNotes("myPowerpointFile.pptx","myBlankpowerpointFile.pptx") That's it... if you see any error, try re-running it (sometimes, for a reason I don't know, it may fail the first attempt). Good luck with it |
#13
|
|||
|
|||
Hello!
Thank you again for your effort, I tried it, as instructed, but I get an error, please see screenshots, which does not go away after the first attempt |
#14
|
|||
|
|||
Hi again.
I see that you are calling the function correctly... wondering what could be the problem. Please check the following: - Both files ("PRHR MASK_TRAINING PRESENTATION_notes.pptx" and "PRHR MASK_TRAINING PRESENTATION_NOnotes.pptx") are already open and editable (make sure they are not opened as read only). - The number of slides in each presentation matches and the starting slide number is similar (whether they start with slide #1 or slide #0). When you enter the debug mode (where the yellow highlight shows up, in your second screenshot), hover your mouse over the "i" in "oSource.Slides(i)....." and it should show you the value of "i", which would be the slide number where the error occurred... this might help troubleshoot in case there's a particular slide causing the issue... if it's 1, that means it's happening in the first iteration, so there is something preventing the script from working... You may want to also hove over each variable while stopped in debug mode to double check that each of them is loaded properly... that is, "mySource" and "myTarget" (should have the filenames), "oSource.Slides.Count" and "oTarget.Slides.Count" should both have a number (the count of slides in each presentation, that should be similar)... Let's see if this helps you figure out what the problem is... I'm happy to take a look at your files if you wish, but I understand that sending your content to someone you don't know is not quite recommended |
#15
|
|||
|
|||
Used to Work But Not Anymore
Quote:
|
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
PowerPoint Macro - Copy and Replace pictures from one PPT to another PPT | mrayncrental | PowerPoint | 2 | 06-09-2014 02:52 AM |
Macro to copy formula from one cell to another | anwar | Excel Programming | 1 | 04-25-2014 08:27 PM |
Word macro: copy from different tables into one table | adisl | Word VBA | 4 | 03-25-2014 02:40 AM |
How to do an automation for copy paste, added new row (macro) | jpol | Excel Programming | 1 | 03-01-2013 05:53 AM |
Powerpoint copy notes | no1_titch | PowerPoint | 0 | 09-07-2010 06:16 AM |