Doctor Who Cuttings Archive

Difference between revisions of "Template:Article"

From The Doctor Who Cuttings Archive
Jump to navigationJump to search
Line 79: Line 79:
 
| text              = <br />
 
| text              = <br />
 
}}
 
}}
 +
<pre>Sub filetoCuttings()
 +
 +
    Application.DisplayAlerts = wdAlertsNone
 +
   
 +
    Selection.WholeStory
 +
    Selection.Find.ClearFormatting
 +
    Selection.Find.Replacement.ClearFormatting
 +
    With Selection.Find
 +
        .Text = "File:"
 +
        .Replacement.Text = ""
 +
        .Forward = True
 +
        .Wrap = wdFindAsk
 +
        .Format = False
 +
        .MatchCase = False
 +
        .MatchWholeWord = False
 +
        .MatchWildcards = False
 +
        .MatchSoundsLike = False
 +
        .MatchAllWordForms = False
 +
    End With
 +
    Selection.Find.Execute Replace:=wdReplaceAll
 +
    With Selection.Find
 +
        .Text = "^p"
 +
        .Replacement.Text = ""
 +
        .Forward = True
 +
        .Wrap = wdFindAsk
 +
        .Format = False
 +
        .MatchCase = False
 +
        .MatchWholeWord = False
 +
        .MatchWildcards = False
 +
        .MatchSoundsLike = False
 +
        .MatchAllWordForms = False
 +
    End With
 +
    Selection.Find.Execute Replace:=wdReplaceAll
 +
 +
    Selection.WholeStory
 +
    FName = Selection
 +
   
 +
    FName = Trim(FName)
 +
    ftype = Mid(FName, Len(FName) - 3, 3)
 +
    FName = Left(FName, Len(FName) - 5)
 +
   
 +
    pos = InStr(FName, " ")
 +
    fdate = Left(FName, pos - 1)
 +
    FName = Mid(FName, pos + 1)
 +
    p = Right(FName, 3)
 +
    p = Trim(p)
 +
    If p Like "p#" Then
 +
        p = Right(p, 1)
 +
        FName = Left(FName, Len(FName) - 3)
 +
    ElseIf p Like "p##" Then
 +
        p = Right(p, 2)
 +
        FName = Left(FName, Len(FName) - 4)
 +
    Else
 +
        p = ""
 +
    End If
 +
     
 +
    out = "{{article" & vbCrLf & "| publication = " & FName & vbCrLf
 +
    out = out & "| file = " & fdate & " " & FName & "." & ftype & vbCrLf
 +
    out = out & "| px = "
 +
    If ftype = "jpg" Then out = out & "450"
 +
    out = out & vbCrLf & "| height = " & vbCrLf
 +
    out = out & "| width = " & vbCrLf & "| date = " & fdate & vbCrLf
 +
    If Len(fdate) < 10 Then out = out & "| display date = " & vbCrLf
 +
    out = out & "| author = " & vbCrLf & "| pages = " & p & vbCrLf & "| language = English " & vbCrLf
 +
    out = out & "| type = " & vbCrLf & "| description = " & vbCrLf & "| categories = " & vbCrLf
 +
    out = out & "| moreTitles = " & vbCrLf & "| morePublications = " & vbCrLf & "| moreDates = " & vbCrLf
 +
    out = out & "| text = " & vbCrLf & "}}"
 +
   
 +
    Selection.TypeText (out)
 +
End Sub
 +
</pre>
 
</noinclude>
 
</noinclude>

Revision as of 03:44, 22 May 2014


{{article
| publication =
| file =
| px =
| height =
| width =
| date =
| author =
| pages =
| language = English
| type =
| description =
| categories =
| moreTitles =
| morePublications =
| moreDates =
| text =
}}

Sub filetoCuttings()

    Application.DisplayAlerts = wdAlertsNone
    
    Selection.WholeStory
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "File:"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
        .Text = "^p"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

    Selection.WholeStory
    FName = Selection
    
    FName = Trim(FName)
    ftype = Mid(FName, Len(FName) - 3, 3)
    FName = Left(FName, Len(FName) - 5)
    
    pos = InStr(FName, " ")
    fdate = Left(FName, pos - 1)
    FName = Mid(FName, pos + 1)
    p = Right(FName, 3)
    p = Trim(p)
    If p Like "p#" Then
        p = Right(p, 1)
        FName = Left(FName, Len(FName) - 3)
    ElseIf p Like "p##" Then
        p = Right(p, 2)
        FName = Left(FName, Len(FName) - 4)
    Else
        p = ""
    End If
       
    out = "{{article" & vbCrLf & "| publication = " & FName & vbCrLf
    out = out & "| file = " & fdate & " " & FName & "." & ftype & vbCrLf
    out = out & "| px = "
    If ftype = "jpg" Then out = out & "450"
    out = out & vbCrLf & "| height = " & vbCrLf
    out = out & "| width = " & vbCrLf & "| date = " & fdate & vbCrLf
    If Len(fdate) < 10 Then out = out & "| display date = " & vbCrLf
    out = out & "| author = " & vbCrLf & "| pages = " & p & vbCrLf & "| language = English " & vbCrLf
    out = out & "| type = " & vbCrLf & "| description = " & vbCrLf & "| categories = " & vbCrLf
    out = out & "| moreTitles = " & vbCrLf & "| morePublications = " & vbCrLf & "| moreDates = " & vbCrLf
    out = out & "| text = " & vbCrLf & "}}"
    
    Selection.TypeText (out)
End Sub