View Single Post
 
Old 09-01-2016, 07:34 AM
uday.word uday.word is offline Windows 7 32bit Office 2013
Novice
 
Join Date: Sep 2016
Posts: 2
uday.word is on a distinguished road
Default VBA to split word document containing pictures using delimter

I have been using the below code to split word documents to multiple sub documents with the help of delimiter. Now my word file contains pictures inserted between the text and this macro is not able to read them. This macro simply splits the text only.

Can any one please help me on this?? I need the macro to work on pictures as well and gets split accordingly.

Option Explicit

Sub SplitNotes(delim As String, strFilename As String)
Dim doc As Document
Dim arrNotes
Dim I As Long
Dim X As Long
Dim Response As Integer

arrNotes = Split(ActiveDocument.Range, delim)

Response = MsgBox("This will split the document into " & UBound(arrNotes) + 1 & " sections. Do you wish to proceed?", 4)
If Response = 7 Then Exit Sub
For I = LBound(arrNotes) To UBound(arrNotes)
If Trim(arrNotes(I)) <> "" Then
X = X + 1
Set doc = Documents.Add
doc.Range = arrNotes(I)
doc.SaveAs ThisDocument.Path & "\" & strFilename & Format(X, "000")
doc.Close True
End If
Next I
End Sub


Sub test()
' delimiter & filename
SplitNotes "///", "Notes "
End Sub


Any solution on this helpful. Many thanks!
Reply With Quote