2017-02-21 2 views
0

ノートを別の.txtファイルにエクスポートするためのMicrosoft Powerpoint 365用の次のマクロがあります。問題は、ノート内にあるノートから箇条書きポイントを除外していることです。この問題を解決するにはどうすればよいですか?書式付きのノートをエクスポートする

Sub ExportNotesText() 

    Dim oSlides As Slides 
    Dim oSl As Slide 
    Dim oSh As Shape 
    Dim strNotesText As String 
    Dim strFileName As String 
    Dim intFileNum As Integer 
    Dim lngReturn As Long 

    ' Get a filename to store the collected text 
    strFileName = InputBox("Enter the full path and name of file to extract notes text to", "Output file?", ActivePresentation.Path + "\notes.txt") 

    ' did user cancel? 
    If strFileName = "" Then 
     Exit Sub 
    End If 

    ' is the path valid? crude but effective test: try to create the file. 
    intFileNum = FreeFile() 
    On Error Resume Next 
    Open strFileName For Output As intFileNum 
    If Err.Number <> 0 Then  ' we have a problem 
     MsgBox "Couldn't create the file: " & strFileName & vbCrLf _ 
      & "Please try again." 
     Exit Sub 
    End If 
    Close #intFileNum ' temporarily 

    ' Get the notes text 
    Set oSlides = ActivePresentation.Slides 
    For Each oSl In oSlides 
     For Each oSh In oSl.NotesPage.Shapes 
     If oSh.PlaceholderFormat.Type = ppPlaceholderBody Then 
      If oSh.HasTextFrame Then 
       If oSh.TextFrame.HasText Then 
        strNotesText = strNotesText & "Slide: " & CStr(oSl.SlideIndex) & vbCrLf _ 
        & oSh.TextFrame.TextRange.Text & vbCrLf & vbCrLf 
       End If 
      End If 
     End If 
     Next oSh 
    Next oSl 

    ' now write the text to file 
    Open strFileName For Output As intFileNum 
    Print #intFileNum, strNotesText 
    Close #intFileNum 

    ' show what we've done 
    ' lngReturn = Shell("NOTEPAD.EXE " & strFileName, vbNormalFocus) 

End Sub 
+0

おそらくファイル名を取得するために 'InputBox'の代わりに実際のダイアログを使うべきでしょう。また、 'strNotesText'には箇条書きのようなものが含まれていますか?あなたの質問はおそらく 'Get the notes text'の部分に絞られるべきです。 –

+2

通常、別のソースからコピーしたコードの属性を提供するのは「完了したこと」です。個人的には、私はあまり気にしていないので、あなたがコピーしたコード、NBDです。他の人は怒られるかもしれません。期限が到来している場所にクレジットを与える(または責任を負う)のは良い習慣です。 IAC、TXTファイルには通常弾丸が表示されません。おそらく別の文字、アスタリスクでそれらを表現したかったでしょうか? –

+0

@SteveRindsberg私はスティーブを謝罪しますが、私は通常、このマクロをしばらくセットしておいて、そのソースを覚えていませんでした。 – Dan

答えて

2

NotesTextFrameへの参照を取得したら、.TextRange.Paragraphsコレクションをループすることができます。

これはあなたにアスタリスク&スペース&なし箇条書きであれば、段落またはテキストだけのテキストを提供します:

If .Paragraphs(x).ParagraphFormat.Bullet.Type = ppBulletUnnumbered Then 
    Debug.Print "* " & .Paragraphs(x).Text 
Else 
    Debug.Print .Paragraphs(x).Text 
End if 

をもあり、番号または箇条書きを想像することができます。そこに行こう。

関連する問題