E
E B
Hi,
I Have a word document that is automatically generated by an application.
This document refers to subdocuments but some of them are (sometime)
missing.
I'd like to write a vba macro which will check all subdocuments and will
create the missing ones.
The following code does not work:
Sub createMissingSubDocuments()
For Each sd In ActiveDocument.Subdocuments
file_path = sd.Path & Application.PathSeparator & sd.Name
If sd.HasFile = True Then
'MsgBox subdoc.Path & Application.PathSeparator & subdoc.Name
Else
Documents.Add.SaveAs FileName:=file_path,
fileformat:=wdFormatRTF
End If
Next
End Sub
When reaching Documents.Add.saveAs ... an error is raised saying that
the file already exists (but actually it does not exist)
I Have a word document that is automatically generated by an application.
This document refers to subdocuments but some of them are (sometime)
missing.
I'd like to write a vba macro which will check all subdocuments and will
create the missing ones.
The following code does not work:
Sub createMissingSubDocuments()
For Each sd In ActiveDocument.Subdocuments
file_path = sd.Path & Application.PathSeparator & sd.Name
If sd.HasFile = True Then
'MsgBox subdoc.Path & Application.PathSeparator & subdoc.Name
Else
Documents.Add.SaveAs FileName:=file_path,
fileformat:=wdFormatRTF
End If
Next
End Sub
When reaching Documents.Add.saveAs ... an error is raised saying that
the file already exists (but actually it does not exist)