Einzelnachweise nachträglich zu Mehrfachnachweisen zusammenführen

Claudius E. hinzugefügt 5 Monaten her
beantwortet

Das Thema ist schon älter und da ich momentan das gleiche Problem habe, wollte ich fragen, ob sich in der Zwischenzeit etwas getan hat. https://support.citavi.com/forum/viewtopic.php?f=156&t=8037


Bei mir ist das Problem dadurch aufgetreten, dass ich im Dokument zunächst die einzelnen Wissensbeiträge samt Kernaussage eingefügt habe und daraus dann später einen Text gebaut habe. Nun wäre es schön, die Einzelnachweise zusammenfassen zu können.

Antworten (18)

Foto
1

Hallo Claudius,

vielen Dank fürs Nachhaken.

Leider ist es weiterhin nicht möglich, Einzelnachweise nachträglich automatisch zu Mehrfachnachweisen zusammenzuführen, siehe Handbuch. Für Ihren Workflow wäre die Möglichkeit natürlich ideal, ist aber technisch nicht einfach umzusetzen.

Viele Grüße

Jana

Foto
1

Hallo Jana,


wie es aussieht, scheint das doch relativ einfach umsetzbar zu sein (siehe Link unten, da ist die Rede von 90 Minuten Aufwand für das Skript).


Gerade dadurch, dass Citavi die Möglichkeit anbietet, Wissen zu organisieren und dann in Word einzufügen, ist eine solche Funktion sehr wichtig, wenn man die gebotenen Optionen denn auch effektiv nutzen möchte. Ich gebe zu bedenken, dass der Workflow, den ich nutze so wie ich das sehe von Citavi auch explizit beworben wird.

Foto
1

Hallo Claudius

Sie haben absolut Recht: möchten Sie einen Aussage, die in mehreren Wissenselementen festgehalten wurde, zu einem Absatz mit den verschiedenen Nachweisen als Mehrfachnachweis zusammenführen, ist Handarbeit nötig.


Nachträglich einzelne Nachweise von Wissenselementen nicht automatisch zusammenfügen zu können, ist ein "Muddy Point" des Citavi Word Add-ins.


Ob es technisch innerhalb des Word Add-ins so schnell und leicht umzusetzen ist wie das VBA-Makro, kann ich leider nicht abschätzen.

Aktuell liegt der Fokus unserer Entwicklung jedoch nicht auf dem Word Add-in, sondern auf Citavi Web, auf das sich all unsere Ressourcen konzentrieren.

Viele Grüße

Jana

Foto
1

Schade, dass sich darauf "alle Ressourcen" konzentrieren, wenn Citavi was einige Funktionen angeht noch unvollständig ist, sodass es nicht so genutzt werden kann, wie gedacht.

Foto
Foto
2

Das ist genau der Grund, aus dem ich die Funktion auch unerlässlich finde. Das ging in Citavi 5 auch per Word-VBA-Skript. Mit Citavi 6 funktioniert das Skript nicht mehr, aber ich hoffe, das lässt sich reparieren, da sich ja vermutlich "nur" die Art der Felder in Word geändert hat.

Foto
1

Also 90 Minuten habe ich für das Skript für Citavi 5 gebraucht, ich weiß nicht so Recht, wie man das für Citavi 6 anpassen muss. Citavi 6 hat die Felder jetzt in Content Controls gesteckt, wie Word das nennt. Bei denen klappt das Makro nicht mehr, aber ich gehe davon aus, dass sich das ändern lässt, ich weiß nur nicht wie.

Foto
1

Das Problem mit den Content Controls habe ich zwar im Griff, aber leider ist auch die Struktur der Felder viel, viel komplizierter geworden. Wenn man den Inhalt eines Feldes decodet, kommt etwa das hier heraus:


{"$id":"1","Entries":[{"$id":"2","Id":"2a63b55c-fdbe-48b2-8140-7b30448a02d9","RangeLength":96,"ReferenceId":"2d7e3b89-b4e7-4ffa-98c1-b6dbfee09df2","PageRange":{"$id":"3","EndPage":{"$id":"4","IsFullyNumeric":false,"NumberingType":0,"NumeralSystem":0},"OriginalString":"22","StartPage":{"$id":"5","IsFullyNumeric":true,"NumberingType":0,"NumeralSystem":0,"OriginalString":"22","PrettyString":"22"}},"Reference":{"$id":"6","AbstractComplexity":0,"AbstractSourceTextFormat":0,"Authors":[{"$id":"7","FirstName":"Ernest","LastName":"Weinrib","MiddleName":"Joseph","Protected":false,"Sex":2,"CreatedBy":"_JJB","CreatedOn":"2015-10-30T19:09:22","ModifiedBy":"_JJB","Id":"77f54916-b7de-4d9c-ac78-b67b9d70d92e","ModifiedOn":"2018-03-12T21:21:02","Project":{"$id":"8"}}],"CitationKeyUpdateType":0,"Collaborators":[],"CustomField6":"page","Editors":[],"Edition":"2","EvaluationComplexity":0,"EvaluationSourceTextFormat":0,"Groups":[],"HasLabel1":false,"HasLabel2":false,"Keywords":[],"Language":"eng","LanguageCode":"en","Locations":[],"Organizations":[],"OthersInvolved":[],"PlaceOfPublication":"Oxford","Publishers":[{"$id":"9","Name":"Oxford University Press","Protected":false,"CreatedBy":"_JJB","CreatedOn":"2015-08-03T15:43:12","ModifiedBy":"_JJB","Id":"4f6c5fe3-29ac-429b-b521-971ac79ae12e","ModifiedOn":"2018-03-12T21:21:02","Project":{"$ref":"8"}}],"Quotations":[],"ReferenceType":"Book","ShortTitle":"Weinrib, The idea of private law (2012)","ShortTitleUpdateType":1,"SourceOfBibliographicInformation":"BibTeX","StaticIds":["5d629ca5-0ab4-4e13-b6e9-9d236d48c7b4"],"TableOfContentsComplexity":0,"TableOfContentsSourceTextFormat":0,"Tasks":[],"Title":"The idea of private law","Translators":[],"Year":"2012","YearResolved":"2012","CreatedBy":"_JJB","CreatedOn":"2015-10-30T19:10:43","ModifiedBy":"_JJB","Id":"2d7e3b89-b4e7-4ffa-98c1-b6dbfee09df2","ModifiedOn":"2018-08-01T20:42:23","Project":{"$ref":"8"}},"UseNumberingTypeOfParentDocument":false}],"FormattedText":{"$id":"10","Count":3,"TextUnits":[{"$id":"11","FontStyle":{"$id":"12","Neutral":true},"ReadingOrder":1,"Text":"Ernest J Weinrib, "},{"$id":"13","FontStyle":{"$id":"14","Italic":true},"ReadingOrder":1,"Text":"The Idea of Private Law"},{"$id":"15","FontStyle":{"$id":"16","Neutral":true},"ReadingOrder":1,"Text":", 2nd edn (Oxford: Oxford University Press, 2012) at 22"}]},"Tag":"CitaviPlaceholder#405c8d5f-a82f-4825-bb87-34e5fe0e00e2","Text":"Ernest J Weinrib, The Idea of Private Law, 2nd edn (Oxford: Oxford University Press, 2012) at 22","WAIVersion":"6.1.0.0"}
Das kann man sich mal auf http://json.parser.online.fr/ angucken, um es lesbar zu machen. Jetzt stellen wir uns mal vor, ich will

{"$id":"1","Entries":[{"$id":"2","Id":"2a63b55c-fdbe-48b2-8140-7b30448a02d9","RangeLength":96,"ReferenceId":"2d7e3b89-b4e7-4ffa-98c1-b6dbfee09df2","PageRange":{"$id":"3","EndPage":{"$id":"4","IsFullyNumeric":false,"NumberingType":0,"NumeralSystem":0},"OriginalString":"22","StartPage":{"$id":"5","IsFullyNumeric":true,"NumberingType":0,"NumeralSystem":0,"OriginalString":"22","PrettyString":"22"}},"Reference":{"$id":"6","AbstractComplexity":0,"AbstractSourceTextFormat":0,"Authors":[{"$id":"7","FirstName":"Ernest","LastName":"Weinrib","MiddleName":"Joseph","Protected":false,"Sex":2,"CreatedBy":"_JJB","CreatedOn":"2015-10-30T19:09:22","ModifiedBy":"_JJB","Id":"77f54916-b7de-4d9c-ac78-b67b9d70d92e","ModifiedOn":"2018-03-12T21:21:02","Project":{"$id":"8"}}],"CitationKeyUpdateType":0,"Collaborators":[],"CustomField6":"page","Editors":[],"Edition":"2","EvaluationComplexity":0,"EvaluationSourceTextFormat":0,"Groups":[],"HasLabel1":false,"HasLabel2":false,"Keywords":[],"Language":"eng","LanguageCode":"en","Locations":[],"Organizations":[],"OthersInvolved":[],"PlaceOfPublication":"Oxford","Publishers":[{"$id":"9","Name":"Oxford University Press","Protected":false,"CreatedBy":"_JJB","CreatedOn":"2015-08-03T15:43:12","ModifiedBy":"_JJB","Id":"4f6c5fe3-29ac-429b-b521-971ac79ae12e","ModifiedOn":"2018-03-12T21:21:02","Project":{"$ref":"8"}}],"Quotations":[],"ReferenceType":"Book","ShortTitle":"Weinrib, The idea of private law (2012)","ShortTitleUpdateType":1,"SourceOfBibliographicInformation":"BibTeX","StaticIds":["5d629ca5-0ab4-4e13-b6e9-9d236d48c7b4"],"TableOfContentsComplexity":0,"TableOfContentsSourceTextFormat":0,"Tasks":[],"Title":"The idea of private law","Translators":[],"Year":"2012","YearResolved":"2012","CreatedBy":"_JJB","CreatedOn":"2015-10-30T19:10:43","ModifiedBy":"_JJB","Id":"2d7e3b89-b4e7-4ffa-98c1-b6dbfee09df2","ModifiedOn":"2018-08-01T20:42:23","Project":{"$ref":"8"}},"UseNumberingTypeOfParentDocument":false}],"FormattedText":{"$id":"10","Count":3,"TextUnits":[{"$id":"11","FontStyle":{"$id":"12","Neutral":true},"ReadingOrder":1,"Text":"Ernest J Weinrib, "},{"$id":"13","FontStyle":{"$id":"14","Italic":true},"ReadingOrder":1,"Text":"The Idea of Private Law"},{"$id":"15","FontStyle":{"$id":"16","Neutral":true},"ReadingOrder":1,"Text":", 2nd edn (Oxford: Oxford University Press, 2012) at 22"}]},"Tag":"CitaviPlaceholder#405c8d5f-a82f-4825-bb87-34e5fe0e00e2","Text":"Ernest J Weinrib, The Idea of Private Law, 2nd edn (Oxford: Oxford University Press, 2012) at 22","WAIVersion":"6.1.0.0"}
und

{"$id":"1","Entries":[{"$id":"2","Id":"eda2d4ad-a264-4ec9-95fb-a9c6eff59ed3","RangeLength":110,"ReferenceId":"ecfe7d5a-5ab6-43b4-bd92-1a62e4de6c09","PageRange":{"$id":"3","EndPage":{"$id":"4","IsFullyNumeric":true,"NumberingType":0,"NumeralSystem":0,"OriginalString":"96","PrettyString":"96"},"OriginalString":"94-96","StartPage":{"$id":"5","IsFullyNumeric":true,"NumberingType":0,"NumeralSystem":0,"OriginalString":"94","PrettyString":"94"}},"QuotationType":1,"Reference":{"$id":"6","AbstractComplexity":0,"AbstractSourceTextFormat":0,"Authors":[{"$id":"7","FirstName":"Marietta","LastName":"Auer","Protected":false,"Sex":1,"CreatedBy":"_JJB","CreatedOn":"2015-10-30T19:09:22","ModifiedBy":"_JJB","Id":"d5c622a5-819f-40de-af06-d52688feb80a","ModifiedOn":"2018-03-12T21:21:02","Project":{"$id":"8"}}],"CitationKey":"Diskurs","CitationKeyUpdateType":1,"Collaborators":[],"CustomField6":"page","Editors":[],"EvaluationComplexity":0,"EvaluationSourceTextFormat":0,"Groups":[],"HasLabel1":false,"HasLabel2":false,"Keywords":[],"Language":"deu","LanguageCode":"de","Locations":[],"Organizations":[],"OthersInvolved":[],"PlaceOfPublication":"Tübingen","Publishers":[{"$id":"9","Name":"Mohr Siebeck","Protected":false,"CreatedBy":"_JJB","CreatedOn":"2015-10-30T19:10:43","ModifiedBy":"_JJB","Id":"86b5d3fd-c43a-4d7b-adb6-64c5839eaf0b","ModifiedOn":"2018-03-12T21:21:02","Project":{"$ref":"8"}}],"Quotations":[],"ReferenceType":"Book","ShortTitle":"Auer, Diskurs (2014)","ShortTitleUpdateType":1,"SourceOfBibliographicInformation":"BibTeX","StaticIds":["e0727d08-a350-41d4-b138-e174fcc4e2e7"],"TableOfContentsComplexity":0,"TableOfContentsSourceTextFormat":0,"Tasks":[],"Title":"Der privatrechtliche Diskurs der Moderne","Translators":[],"Year":"2014","YearResolved":"2014","CreatedBy":"_JJB","CreatedOn":"2015-10-30T19:10:43","ModifiedBy":"_JJB","Id":"ecfe7d5a-5ab6-43b4-bd92-1a62e4de6c09","ModifiedOn":"2018-08-01T20:42:23","Project":{"$ref":"8"}},"UseNumberingTypeOfParentDocument":false}],"FormattedText":{"$id":"10","Count":5,"TextUnits":[{"$id":"11","FontStyle":{"$id":"12","Neutral":true},"ReadingOrder":1,"Text":"Marietta Auer, "},{"$id":"13","FontStyle":{"$id":"14","Italic":true},"ReadingOrder":1,"Text":"Der privatrechtliche Diskurs der Moderne"},{"$id":"15","FontStyle":{"$id":"16","Neutral":true},"ReadingOrder":1,"Text":" (Tübingen: Mohr Siebeck, 2014) at 94–6 [Auer, "},{"$id":"17","FontStyle":{"$id":"18","Italic":true},"ReadingOrder":1,"Text":"Diskurs"},{"$id":"19","FontStyle":{"$id":"20","Neutral":true},"ReadingOrder":1,"Text":"]"}]},"Tag":"CitaviPlaceholder#b590d1d4-ec91-436b-ba2f-e15b9bc4f17b","Text":"Marietta Auer, Der privatrechtliche Diskurs der Moderne (Tübingen: Mohr Siebeck, 2014) at 94–6 [Auer, Diskurs]","WAIVersion":"6.1.0.0"}
kombinieren. Ich weiß noch nicht wie. In Citavi 5 konnte man zwei PlaceholderEntries noch hintereinander klatschen, und Citavi hat das schon irgendwie verarbeitet. In Citavi 6 versuche ich, die beiden wie folgt zu kombinieren:

{"$id": "1","Entries": [{"$id": "2","Id": "2a63b55c-fdbe-48b2-8140-7b30448a02d9","RangeLength": 96,"ReferenceId": "2d7e3b89-b4e7-4ffa-98c1-b6dbfee09df2","PageRange": {"$id": "3","EndPage": {"$id": "4","IsFullyNumeric": false,"NumberingType": 0,"NumeralSystem": 0},"OriginalString": "22","StartPage": {"$id": "5","IsFullyNumeric": true,"NumberingType": 0,"NumeralSystem": 0,"OriginalString": "22","PrettyString": "22"}},"Reference": {"$id": "6","AbstractComplexity": 0,"AbstractSourceTextFormat": 0,"Authors": [{"$id": "7","FirstName": "Ernest","LastName": "Weinrib","MiddleName": "Joseph","Protected": false,"Sex": 2,"CreatedBy": "_JJB","CreatedOn": "2015-10-30T19:09:22","ModifiedBy": "_JJB","Id": "77f54916-b7de-4d9c-ac78-b67b9d70d92e","ModifiedOn": "2018-03-12T21:21:02","Project": {"$id": "8"}}],"CitationKeyUpdateType": 0,"Collaborators": [],"CustomField6": "page","Editors": [],"Edition": "2","EvaluationComplexity": 0,"EvaluationSourceTextFormat": 0,"Groups": [],"HasLabel1": false,"HasLabel2": false,"Keywords": [],"Language": "eng","LanguageCode": "en","Locations": [],"Organizations": [],"OthersInvolved": [],"PlaceOfPublication": "Oxford","Publishers": [{"$id": "9","Name": "Oxford University Press","Protected": false,"CreatedBy": "_JJB","CreatedOn": "2015-08-03T15:43:12","ModifiedBy": "_JJB","Id": "4f6c5fe3-29ac-429b-b521-971ac79ae12e","ModifiedOn": "2018-03-12T21:21:02","Project": {"$ref": "8"}}],"Quotations": [],"ReferenceType": "Book","ShortTitle": "Weinrib, The idea of private law (2012)","ShortTitleUpdateType": 1,"SourceOfBibliographicInformation": "BibTeX","StaticIds": ["5d629ca5-0ab4-4e13-b6e9-9d236d48c7b4"],"TableOfContentsComplexity": 0,"TableOfContentsSourceTextFormat": 0,"Tasks": [],"Title": "The idea of private law","Translators": [],"Year": "2012","YearResolved": "2012","CreatedBy": "_JJB","CreatedOn": "2015-10-30T19:10:43","ModifiedBy": "_JJB","Id": "2d7e3b89-b4e7-4ffa-98c1-b6dbfee09df2","ModifiedOn": "2018-08-01T20:42:23","Project": {"$ref": "8"}},"UseNumberingTypeOfParentDocument": false},{"$id": "10","Id": "eda2d4ad-a264-4ec9-95fb-a9c6eff59ed3","RangeLength": 110,"ReferenceId": "ecfe7d5a-5ab6-43b4-bd92-1a62e4de6c09","PageRange": {"$id": "11","EndPage": {"$id": "12","IsFullyNumeric": true,"NumberingType": 0,"NumeralSystem": 0,"OriginalString": "96","PrettyString": "96"},"OriginalString": "94-96","StartPage": {"$id": "13","IsFullyNumeric": true,"NumberingType": 0,"NumeralSystem": 0,"OriginalString": "94","PrettyString": "94"}},"QuotationType": 1,"Reference": {"$id": "14","AbstractComplexity": 0,"AbstractSourceTextFormat": 0,"Authors": [{"$id": "15","FirstName": "Marietta","LastName": "Auer","Protected": false,"Sex": 1,"CreatedBy": "_JJB","CreatedOn": "2015-10-30T19:09:22","ModifiedBy": "_JJB","Id": "d5c622a5-819f-40de-af06-d52688feb80a","ModifiedOn": "2018-03-12T21:21:02","Project": {"$id": "16"}}],"CitationKey": "Diskurs","CitationKeyUpdateType": 1,"Collaborators": [],"CustomField6": "page","Editors": [],"EvaluationComplexity": 0,"EvaluationSourceTextFormat": 0,"Groups": [],"HasLabel1": false,"HasLabel2": false,"Keywords": [],"Language": "deu","LanguageCode": "de","Locations": [],"Organizations": [],"OthersInvolved": [],"PlaceOfPublication": "T\u00C3\u00BCbingen","Publishers": [{"$id": "17","Name": "Mohr Siebeck","Protected": false,"CreatedBy": "_JJB","CreatedOn": "2015-10-30T19:10:43","ModifiedBy": "_JJB","Id": "86b5d3fd-c43a-4d7b-adb6-64c5839eaf0b","ModifiedOn": "2018-03-12T21:21:02","Project": {"$ref": "8"}}],"Quotations": [],"ReferenceType": "Book","ShortTitle": "Auer, Diskurs (2014)","ShortTitleUpdateType": 1,"SourceOfBibliographicInformation": "BibTeX","StaticIds": ["e0727d08-a350-41d4-b138-e174fcc4e2e7"],"TableOfContentsComplexity": 0,"TableOfContentsSourceTextFormat": 0,"Tasks": [],"Title": "Der privatrechtliche Diskurs der Moderne","Translators": [],"Year": "2014","YearResolved": "2014","CreatedBy": "_JJB","CreatedOn": "2015-10-30T19:10:43","ModifiedBy": "_JJB","Id": "ecfe7d5a-5ab6-43b4-bd92-1a62e4de6c09","ModifiedOn": "2018-08-01T20:42:23","Project": {"$ref": "8"}},"UseNumberingTypeOfParentDocument": false}],"FormattedText": {"$id": "10","Count": 3,"TextUnits": [{"$id": "11","FontStyle": {"$id": "12","Neutral": true},"ReadingOrder": 1,"Text": "Ernest J Weinrib, "},{"$id": "13","FontStyle": {"$id": "14","Italic": true},"ReadingOrder": 1,"Text": "The Idea of Private Law"},{"$id": "15","FontStyle": {"$id": "16","Neutral": true},"ReadingOrder": 1,"Text": ", 2nd edn (Oxford: Oxford University Press, 2012) at 22"}]},"Tag": "CitaviPlaceholder#405c8d5f-a82f-4825-bb87-34e5fe0e00e2","Text": "Ernest J Weinrib, The Idea of Private Law, 2nd edn (Oxford: Oxford University Press, 2012) at 22","WAIVersion": "6.1.0.0"}
Das klappt aber nicht, danach sieht das dann wie im Screenshot aus. Jede Hilfe für's Kombinieren der JSON-Dingsbumsdas ist willkommen.


Hier ist mein ganzes Makro bisher, die JSON-Tools, die dazu benötigt werden, gibt es hier.


Sub CitaviMergeContentControls()

    Dim selectedContentControlsCount As Long
    Dim contentControlIndex As Long
    
    Dim encodedPlaceholder As String
    Dim decodedPlaceholder As String
    
    Dim newPlaceholderEntries As String
    
    Dim formattedPlaceholders As String

    Dim newFormattedPlaceholderEntries As String
    Dim newFormattedPlaceholderBeginning As String
    Dim newFormattedPlaceholderEnd As String
    
    Dim newFormattedPlaceholder As String
    
    Dim newEncodedPlaceholder As String
    
    Dim newFieldCode As String
    
    Dim output As String
    
    
    ' Create a regular expression object.
    Set objRegExp = New RegExp


    ' Clipboard Stuff
    
    Dim obj As New DataObject
    Dim txt As String

    Set selectedContentControls = Selection.ContentControls
    
    selectedContentControlsCount = selectedContentControls.Count
    
    i = 1

    For contentControlIndex = 1 To selectedContentControlsCount
    
        For Each Field In selectedContentControls(contentControlIndex).Range.Fields
                        
            encodedPlaceholder = SuperMid(Field.Code, "{", "}")
            decodedPlaceholder = StrConv(DecodeBase64(encodedPlaceholder), vbUnicode)
            
            Dim Json As Object
            Set Json = JsonConverter.ParseJson(decodedPlaceholder)
            
            formattedPlaceholder = JsonConverter.ConvertToJson(Json, Whitespace:=2)
            
            formattedPlaceholders = formattedPlaceholders & formattedPlaceholder
            
            If i = 1 Then

                newFormattedPlaceholderBeginning = ExtractPlaceholderBeginning(formattedPlaceholders)
                newFormattedPlaceholderEnd = ExtractPlaceholderEnd(formattedPlaceholders)

            End If
            
            i = i + 1
            
        Next
    
    Next
    
    newFormattedPlaceholderEntries = RenumberIDs(ExtractPlaceholderEntries(formattedPlaceholders))
    
    newFormattedPlaceholder = newFormattedPlaceholderBeginning & newFormattedPlaceholderEntries & newFormattedPlaceholderEnd
    
    newPlaceholder = Replace(JsonConverter.ConvertToJson(JsonConverter.ParseJson(newFormattedPlaceholder), Whitespace:=0), vbCrLf, "")

    newEncodedPlaceholder = encodeBase64(StrConv(newPlaceholder, vbFromUnicode))
    
    newFieldCode = Replace("ADDIN CitaviPlaceholder{" & newEncodedPlaceholder & "}", vbLf, "")
    

    For contentControlIndex = 1 To selectedContentControlsCount
    
    
        If contentControlIndex = 1 Then
    
            selectedContentControls(contentControlIndex).Range.Fields(1).Code.Text = newFieldCode
            selectedContentControls(contentControlIndex).Range.Fields(1).Update
    
            j = 0
    
            For Each Field In selectedContentControls(contentControlIndex).Range.Fields
                j = j + 1
                If j > 1 Then selectedContentControls(contentControlIndex).Range.Fields(j).Delete
            Next
    
        Else
            selectedContentControls(contentControlIndex).Delete True
    
        End If
    
    
    Next
    


    obj.SetText newPlaceholder
    obj.PutInClipboard
      
End Sub

Private Function RenumberIDs(myString As String)

    Dim objRegExp As RegExp
    
    Set objRegExp = New RegExp
    
    i = 1

    With objRegExp
           .Pattern = "(" & Chr(34) & "\$id" & Chr(34) & ": " & Chr(34) & ")([0-9]+)(" & Chr(34) & ")"
           .Global = False
           .IgnoreCase = True
           .MultiLine = False
           Do While .Test(myString)
               Set objRegMC = .Execute(myString)
               For Each objRegM In objRegMC
                    i = i + 1
                    myString = .Replace(myString, Chr(34) & "$uniqueid" & Chr(34) & ": " & Chr(34) & i & "$3")
               Next
           Loop
    End With
    
    With objRegExp
           .Pattern = "\$uniqueid"
           .Global = False
           .IgnoreCase = True
           .MultiLine = False
           Do While .Test(myString)
               Set objRegMC = .Execute(myString)
               For Each objRegM In objRegMC
                    myString = .Replace(myString, "$id")
               Next
           Loop
    End With
    
    RenumberIDs = myString
   
End Function


Private Function ExtractPlaceholderBeginning(myString As String)
   
    'Create objects.
    Dim objRegExp As RegExp
    Dim objMatch As Match
    Dim colMatches As matchCollection
    
    searchPattern = "^(\s*)([\S\s]+?)(\s*)(\n    {)"
    
    ' Create a regular expression object.
    Set objRegExp = New RegExp
    
    objRegExp.Pattern = searchPattern
    objRegExp.MultiLine = False
    objRegExp.IgnoreCase = True
    objRegExp.Global = False
    
    Set colMatches = objRegExp.Execute(myString)
    
    ExtractPlaceholderBeginning = colMatches(0).SubMatches(0) & colMatches(0).SubMatches(1) & colMatches(0).SubMatches(2)
   
End Function

Private Function ExtractPlaceholderEnd(myString As String)
   
    'Create objects.
    Dim objRegExp As RegExp
    Dim objMatch As Match
    Dim colMatches   As matchCollection
    Dim RetStr As String
    
    searchPattern = "(\n)(  ],)(\s*)([\S\s]+?)(\s*)$"
    
    ' Create a regular expression object.
    Set objRegExp = New RegExp
    
    objRegExp.Pattern = searchPattern
    objRegExp.MultiLine = False
    objRegExp.IgnoreCase = True
    objRegExp.Global = True
    
    Set colMatches = objRegExp.Execute(myString)
    ExtractPlaceholderEnd = colMatches(0).SubMatches(0) & colMatches(0).SubMatches(1) & colMatches(0).SubMatches(2) & colMatches(0).SubMatches(3)
   
End Function

Private Function ExtractPlaceholderEntries(myString As String)
   
    'Create objects.
    Dim objRegExp As RegExp
    Dim objMatch As Match
    Dim colMatches   As matchCollection
    Dim RetStr As String
    
    myPattern = "(\n    {)\s*([\S\s]+?)\s*(\n    })"
    
    ' Create a regular expression object.
    Set objRegExp = New RegExp
    
    objRegExp.Pattern = myPattern
    objRegExp.MultiLine = True
    objRegExp.IgnoreCase = True
    objRegExp.Global = True
    

    Set colMatches = objRegExp.Execute(myString)   ' Execute search.
    
    i = 1
        
    For Each objMatch In colMatches   ' Iterate Matches collection.
        If i < colMatches.Count Then
            RetStr = RetStr & objMatch.Value & ","
        Else
            RetStr = RetStr & objMatch.Value
        End If
        i = i + 1
    Next

    
    ExtractPlaceholderEntries = RetStr
   
End Function

Private Function DecodeBase64(ByVal strData As String) As Byte()
 
    Dim objXML As MSXML2.DOMDocument
    Dim objNode As MSXML2.IXMLDOMElement
    
    ' help from MSXML
    Set objXML = New MSXML2.DOMDocument
    Set objNode = objXML.createElement("b64")
    objNode.dataType = "bin.base64"
    objNode.Text = strData
    DecodeBase64 = objNode.nodeTypedValue
    
    ' thanks, bye
    Set objNode = Nothing
    Set objXML = Nothing
 
End Function

Private Function encodeBase64(ByRef arrData() As Byte) As String
    Dim objXML As MSXML2.DOMDocument
    Dim objNode As MSXML2.IXMLDOMElement
    
    Set objXML = New MSXML2.DOMDocument
    
    Set objNode = objXML.createElement("b64")
    objNode.dataType = "bin.base64"
    objNode.nodeTypedValue = arrData
    encodeBase64 = objNode.Text
 
    Set objNode = Nothing
    Set objXML = Nothing
End Function

Private Function SuperMid(ByVal strMain As String, str1 As String, str2 As String, Optional reverse As Boolean) As String
'DESCRIPTION: Extract the portion of a string between the two substrings defined in str1 and str2.
'DEVELOPER: Ryan Wells (wellsr.com)
'HOW TO USE: - Pass the argument your main string and the 2 strings you want to find in the main string.
' - This function will extract the values between the end of your first string and the beginning
' of your next string.
' - If the optional boolean "reverse" is true, an InStrRev search will occur to find the last
' instance of the substrings in your main string.
Dim i As Integer, j As Integer, temp As Variant
On Error GoTo errhandler:
If reverse = True Then
    i = InStrRev(strMain, str1)
    j = InStrRev(strMain, str2)
    If Abs(j - i) < Len(str1) Then j = InStrRev(strMain, str2, i)
    If i = j Then 'try to search 2nd half of string for unique match
        j = InStrRev(strMain, str2, i - 1)
    End If
Else
    i = InStr(1, strMain, str1)
    j = InStr(1, strMain, str2)
    If Abs(j - i) < Len(str1) Then j = InStr(i + Len(str1), strMain, str2)
    If i = j Then 'try to search 2nd half of string for unique match
        j = InStr(i + 1, strMain, str2)
    End If
End If
If i = 0 And j = 0 Then GoTo errhandler:
If j = 0 Then j = Len(strMain) + Len(str2) 'just to make it arbitrarily large
If i = 0 Then i = Len(strMain) + Len(str1) 'just to make it arbitrarily large
If i > j And j <> 0 Then 'swap order
    temp = j
    j = i
    i = temp
    temp = str2
    str2 = str1
    str1 = temp
End If
i = i + Len(str1)
SuperMid = Mid(strMain, i, j - i)
Exit Function
errhandler:
MsgBox "Error extracting strings. Check your input" & vbNewLine & vbNewLine & "Aborting", , "Strings not found"
End
End Function

Foto
1

Interessant. Ist das Beispiel für das Mehrfachzitat (unten noch mal) auch aus Citavi dekodiert, d.h. so wie es sein sollte, oder nur ein Versuch von dir? Ansonsten ist das ja sicher auch noch hilfreich zu sehen, wie Mehrfachzitate in Citavi aussehen sollten.


{"$id": "1","Entries": [{"$id": "2","Id": "2a63b55c-fdbe-48b2-8140-7b30448a02d9","RangeLength": 96,"ReferenceId": "2d7e3b89-b4e7-4ffa-98c1-b6dbfee09df2","PageRange": {"$id": "3","EndPage": {"$id": "4","IsFullyNumeric": false,"NumberingType": 0,"NumeralSystem": 0},"OriginalString": "22","StartPage": {"$id": "5","IsFullyNumeric": true,"NumberingType": 0,"NumeralSystem": 0,"OriginalString": "22","PrettyString": "22"}},"Reference": {"$id": "6","AbstractComplexity": 0,"AbstractSourceTextFormat": 0,"Authors": [{"$id": "7","FirstName": "Ernest","LastName": "Weinrib","MiddleName": "Joseph","Protected": false,"Sex": 2,"CreatedBy": "_JJB","CreatedOn": "2015-10-30T19:09:22","ModifiedBy": "_JJB","Id": "77f54916-b7de-4d9c-ac78-b67b9d70d92e","ModifiedOn": "2018-03-12T21:21:02","Project": {"$id": "8"}}],"CitationKeyUpdateType": 0,"Collaborators": [],"CustomField6": "page","Editors": [],"Edition": "2","EvaluationComplexity": 0,"EvaluationSourceTextFormat": 0,"Groups": [],"HasLabel1": false,"HasLabel2": false,"Keywords": [],"Language": "eng","LanguageCode": "en","Locations": [],"Organizations": [],"OthersInvolved": [],"PlaceOfPublication": "Oxford","Publishers": [{"$id": "9","Name": "Oxford University Press","Protected": false,"CreatedBy": "_JJB","CreatedOn": "2015-08-03T15:43:12","ModifiedBy": "_JJB","Id": "4f6c5fe3-29ac-429b-b521-971ac79ae12e","ModifiedOn": "2018-03-12T21:21:02","Project": {"$ref": "8"}}],"Quotations": [],"ReferenceType": "Book","ShortTitle": "Weinrib, The idea of private law (2012)","ShortTitleUpdateType": 1,"SourceOfBibliographicInformation": "BibTeX","StaticIds": ["5d629ca5-0ab4-4e13-b6e9-9d236d48c7b4"],"TableOfContentsComplexity": 0,"TableOfContentsSourceTextFormat": 0,"Tasks": [],"Title": "The idea of private law","Translators": [],"Year": "2012","YearResolved": "2012","CreatedBy": "_JJB","CreatedOn": "2015-10-30T19:10:43","ModifiedBy": "_JJB","Id": "2d7e3b89-b4e7-4ffa-98c1-b6dbfee09df2","ModifiedOn": "2018-08-01T20:42:23","Project": {"$ref": "8"}},"UseNumberingTypeOfParentDocument": false},{"$id": "10","Id": "eda2d4ad-a264-4ec9-95fb-a9c6eff59ed3","RangeLength": 110,"ReferenceId": "ecfe7d5a-5ab6-43b4-bd92-1a62e4de6c09","PageRange": {"$id": "11","EndPage": {"$id": "12","IsFullyNumeric": true,"NumberingType": 0,"NumeralSystem": 0,"OriginalString": "96","PrettyString": "96"},"OriginalString": "94-96","StartPage": {"$id": "13","IsFullyNumeric": true,"NumberingType": 0,"NumeralSystem": 0,"OriginalString": "94","PrettyString": "94"}},"QuotationType": 1,"Reference": {"$id": "14","AbstractComplexity": 0,"AbstractSourceTextFormat": 0,"Authors": [{"$id": "15","FirstName": "Marietta","LastName": "Auer","Protected": false,"Sex": 1,"CreatedBy": "_JJB","CreatedOn": "2015-10-30T19:09:22","ModifiedBy": "_JJB","Id": "d5c622a5-819f-40de-af06-d52688feb80a","ModifiedOn": "2018-03-12T21:21:02","Project": {"$id": "16"}}],"CitationKey": "Diskurs","CitationKeyUpdateType": 1,"Collaborators": [],"CustomField6": "page","Editors": [],"EvaluationComplexity": 0,"EvaluationSourceTextFormat": 0,"Groups": [],"HasLabel1": false,"HasLabel2": false,"Keywords": [],"Language": "deu","LanguageCode": "de","Locations": [],"Organizations": [],"OthersInvolved": [],"PlaceOfPublication": "T\u00C3\u00BCbingen","Publishers": [{"$id": "17","Name": "Mohr Siebeck","Protected": false,"CreatedBy": "_JJB","CreatedOn": "2015-10-30T19:10:43","ModifiedBy": "_JJB","Id": "86b5d3fd-c43a-4d7b-adb6-64c5839eaf0b","ModifiedOn": "2018-03-12T21:21:02","Project": {"$ref": "8"}}],"Quotations": [],"ReferenceType": "Book","ShortTitle": "Auer, Diskurs (2014)","ShortTitleUpdateType": 1,"SourceOfBibliographicInformation": "BibTeX","StaticIds": ["e0727d08-a350-41d4-b138-e174fcc4e2e7"],"TableOfContentsComplexity": 0,"TableOfContentsSourceTextFormat": 0,"Tasks": [],"Title": "Der privatrechtliche Diskurs der Moderne","Translators": [],"Year": "2014","YearResolved": "2014","CreatedBy": "_JJB","CreatedOn": "2015-10-30T19:10:43","ModifiedBy": "_JJB","Id": "ecfe7d5a-5ab6-43b4-bd92-1a62e4de6c09","ModifiedOn": "2018-08-01T20:42:23","Project": {"$ref": "8"}},"UseNumberingTypeOfParentDocument": false}],"FormattedText": {"$id": "10","Count": 3,"TextUnits": [{"$id": "11","FontStyle": {"$id": "12","Neutral": true},"ReadingOrder": 1,"Text": "Ernest J Weinrib, "},{"$id": "13","FontStyle": {"$id": "14","Italic": true},"ReadingOrder": 1,"Text": "The Idea of Private Law"},{"$id": "15","FontStyle": {"$id": "16","Neutral": true},"ReadingOrder": 1,"Text": ", 2nd edn (Oxford: Oxford University Press, 2012) at 22"}]},"Tag": "CitaviPlaceholder#405c8d5f-a82f-4825-bb87-34e5fe0e00e2","Text": "Ernest J Weinrib, The Idea of Private Law, 2nd edn (Oxford: Oxford University Press, 2012) at 22","WAIVersion": "6.1.0.0"}

Foto
1

Das war mein ursprünglicher Versuch, zwei Einzelnachweise zu einem Mehrfachnachweis zu verbinden. Das – inzwischen gelöste – Problem war, dass alle $ids neu nummeriert werden mussten, also auch die nach dem letzten UseNumberingTypeOfParentDocument. Mein unteres Makro funktioniert schon relativ gut, scheitert aber manchmal, und haut glaube ich auch die Kodierung durcheinander, was man nach außen nicht sieht, aber der Grund für das Scheitern in manchen Fällen sein mag. Es ist relativ trivial anhand meines Makros zu gucken, wie ein echter Mehrfachnachweis aussieht, indem man an der richtigen Stelle formattedPlaceholder in die Zwischenablage kopiert und dann nur einen einzelnen Mehrfachnachweis in Word anwählt. Hier ist ein Beispiel (indem man auch auch das Kodierungsproblem sieht):

{
   "$id":"1",
   "Entries":[
      {
         "$id":"2",
         "Id":"4578c596-fbc6-4204-9c6c-0be66c0e72b6",
         "RangeStart":334,
         "RangeLength":111,
         "ReferenceId":"0855d012-c29d-4301-b109-b14e88bf608a",
         "PageRange":{
            "$id":"3",
            "EndPage":{
               "$id":"4",
               "IsFullyNumeric":false,
               "NumberingType":3,
               "NumeralSystem":-1
            },
            "StartPage":{
               "$id":"5",
               "IsFullyNumeric":false,
               "NumberingType":3,
               "NumeralSystem":-1
            }
         },
         "Reference":{
            "$id":"6",
            "AbstractComplexity":0,
            "AbstractSourceTextFormat":0,
            "Authors":[
               {
                  "$id":"7",
                  "FirstName":"Tiong",
                  "LastName":"Yeo",
                  "MiddleName":"Min",
                  "Protected":false,
                  "Sex":0,
                  "CreatedBy":"_JJB",
                  "CreatedOn":"2015-10-30T19:10:43",
                  "ModifiedBy":"_JJB",
                  "Id":"8ec1a756-1e5f-4f2f-8c65-84d3b539b42a",
                  "ModifiedOn":"2018-03-12T21:21:02",
                  "Project":{
                     "$id":"8"
                  }
               }
            ],
            "CitationKeyUpdateType":0,
            "Collaborators":[

            ],
            "Editors":[

            ],
            "EvaluationComplexity":0,
            "EvaluationSourceTextFormat":0,
            "Groups":[

            ],
            "HasLabel1":false,
            "HasLabel2":false,
            "Keywords":[

            ],
            "Language":"eng",
            "LanguageCode":"en",
            "Locations":[

            ],
            "Organizations":[

            ],
            "OthersInvolved":[

            ],
            "PlaceOfPublication":"Oxford",
            "Publishers":[
               {
                  "$id":"9",
                  "Name":"Oxford University Press",
                  "Protected":false,
                  "CreatedBy":"_JJB",
                  "CreatedOn":"2015-08-03T15:43:12",
                  "ModifiedBy":"_JJB",
                  "Id":"4f6c5fe3-29ac-429b-b521-971ac79ae12e",
                  "ModifiedOn":"2018-03-12T21:21:02",
                  "Project":{
                     "$ref":"8"
                  }
               }
            ],
            "Quotations":[

            ],
            "ReferenceType":"Book",
            "ShortTitle":"Yeo, Choice of law for equitable doctrines (2004)",
            "ShortTitleUpdateType":1,
            "SourceOfBibliographicInformation":"BibTeX",
            "StaticIds":[
               "ca86a954-a745-4ba0-bafc-d59e7f76acd8"
            ],
            "TableOfContentsComplexity":0,
            "TableOfContentsSourceTextFormat":0,
            "Tasks":[

            ],
            "Title":"Choice of law for equitable doctrines",
            "Translators":[

            ],
            "Year":"2004",
            "YearResolved":"2004",
            "CreatedBy":"_JJB",
            "CreatedOn":"2015-10-30T19:10:43",
            "ModifiedBy":"_Jjbor",
            "Id":"0855d012-c29d-4301-b109-b14e88bf608a",
            "ModifiedOn":"2018-07-09T09:51:02",
            "Project":{
               "$ref":"8"
            }
         },
         "Suffix":" at paras Intr.7-13",
         "UseNumberingTypeOfParentDocument":false,
         "UseStandardPrefix":false,
         "UseStandardSuffix":false
      },
      {
         "$id":"10",
         "Id":"1a33a5d9-5d9a-464a-8889-2a78a5940876",
         "RangeStart":181,
         "RangeLength":153,
         "ReferenceId":"5e5689e8-e3bc-4bb3-95c4-ea74143fae41",
         "PageRange":{
            "$id":"11",
            "EndPage":{
               "$id":"12",
               "IsFullyNumeric":true,
               "NumberingType":0,
               "NumeralSystem":0,
               "OriginalString":"110",
               "PrettyString":"110"
            },
            "OriginalString":"108–110",
            "StartPage":{
               "$id":"13",
               "IsFullyNumeric":true,
               "NumberingType":0,
               "NumeralSystem":0,
               "OriginalString":"108",
               "PrettyString":"108"
            }
         },
         "Reference":{
            "$id":"14",
            "AbstractComplexity":0,
            "AbstractSourceTextFormat":0,
            "Authors":[
               {
                  "$id":"15",
                  "FirstName":"Jack",
                  "LastName":"Wass",
                  "Protected":false,
                  "Sex":2,
                  "CreatedBy":"_JJB",
                  "CreatedOn":"2017-07-15T14:33:20",
                  "ModifiedBy":"_JJB",
                  "Id":"f6d6d770-78e2-43d3-9b73-865cb43d52bc",
                  "ModifiedOn":"2018-03-12T21:21:02",
                  "Project":{
                     "$ref":"8"
                  }
               }
            ],
            "CitationKeyUpdateType":0,
            "Collaborators":[

            ],
            "CustomField6":"page",
            "Editors":[

            ],
            "EvaluationComplexity":0,
            "EvaluationSourceTextFormat":0,
            "Groups":[
               {
                  "$id":"16",
                  "DisplayType":1,
                  "Name":"(4) Dissertation",
                  "CreatedBy":"_JJB",
                  "CreatedOn":"2017-05-12T00:24:43",
                  "ModifiedBy":"_JJB",
                  "Id":"3b0bf58d-8d02-4027-89bd-7af597ffd559",
                  "ModifiedOn":"2018-03-12T21:21:02",
                  "Project":{
                     "$ref":"8"
                  }
               }
            ],
            "HasLabel1":false,
            "HasLabel2":false,
            "Keywords":[

            ],
            "Language":"eng",
            "LanguageCode":"en",
            "Locations":[

            ],
            "Number":"1",
            "Organizations":[

            ],
            "OthersInvolved":[

            ],
            "PageCount":"33",
            "PageCountNumeralSystem":"Arabic",
            "PageRange":"<sp>\r\n  <n>103</n>\r\n  <in>true</in>\r\n  <os>103</os>\r\n  <ps>103</ps>\r\n</sp>\r\n<ep>\r\n  <n>135</n>\r\n  <in>true</in>\r\n  <os>135</os>\r\n  <ps>135</ps>\r\n</ep>\r\n<os>103-135</os>",
            "PageRangeNumber":103,
            "PageRangeNumberingType":"Page",
            "PageRangeNumeralSystem":"Arabic",
            "Periodical":{
               "$id":"17",
               "Name":"International and Comparative Law Quarterly",
               "Pagination":0,
               "Protected":true,
               "StandardAbbreviation":"I.C.L.Q.",
               "CreatedBy":"_JJB",
               "CreatedOn":"2015-10-30T19:09:22",
               "ModifiedBy":"_JJB",
               "Id":"0dd75bf1-bbd8-4f6d-8d3d-4218bde0fef5",
               "ModifiedOn":"2018-03-12T21:21:02",
               "Project":{
                  "$ref":"8"
               }
            },
            "Publishers":[

            ],
            "Quotations":[

            ],
            "ReferenceType":"JournalArticle",
            "ShortTitle":"Wass, The court's in personam jurisdiction in cases involving foreign land (2014)",
            "ShortTitleUpdateType":1,
            "SourceOfBibliographicInformation":"EndNote Tagged Import Format",
            "StaticIds":[
               "de09648d-a998-43fa-b988-e84a673fa721"
            ],
            "TableOfContentsComplexity":0,
            "TableOfContentsSourceTextFormat":0,
            "Tasks":[

            ],
            "Title":"The court's in personam jurisdiction in cases involving foreign land",
            "Translators":[

            ],
            "Volume":"63",
            "Year":"2014",
            "YearResolved":"2014",
            "CreatedBy":"_JJB",
            "CreatedOn":"2017-07-15T14:33:20",
            "ModifiedBy":"_Jjbor",
            "Id":"5e5689e8-e3bc-4bb3-95c4-ea74143fae41",
            "ModifiedOn":"2018-07-09T09:51:02",
            "Project":{
               "$ref":"8"
            }
         },
         "UseNumberingTypeOfParentDocument":false
      },
      {
         "$id":"18",
         "Id":"df022795-93cf-4567-aef9-0a54cecf69e7",
         "RangeLength":181,
         "ReferenceId":"92e5fc03-fa67-4b81-b52a-09d2ea4f8e52",
         "PageRange":{
            "$id":"19",
            "EndPage":{
               "$id":"20",
               "IsFullyNumeric":false,
               "NumberingType":0,
               "NumeralSystem":0
            },
            "OriginalString":"2.037",
            "StartPage":{
               "$id":"21",
               "IsFullyNumeric":false,
               "Number":2,
               "NumberingType":3,
               "NumeralSystem":-1,
               "OriginalString":"2.037",
               "PrettyString":"2.037"
            }
         },
         "Reference":{
            "$id":"22",
            "AbstractComplexity":0,
            "AbstractSourceTextFormat":0,
            "Authors":[

            ],
            "CitationKey":"Dicey, Morris & Collins",
            "CitationKeyUpdateType":1,
            "Collaborators":[

            ],
            "Editors":[
               {
                  "$id":"23",
                  "FirstName":"Lawrence",
                  "LastName":"Collins",
                  "Protected":true,
                  "Suffix":"Baron Collins of Mapesbury",
                  "Sex":2,
                  "CreatedBy":"_JJB",
                  "CreatedOn":"2015-10-30T19:11:21",
                  "ModifiedBy":"_JJB",
                  "Id":"151c0c82-e465-42eb-ac67-3d53c55c791c",
                  "ModifiedOn":"2018-03-12T21:21:02",
                  "Project":{
                     "$ref":"8"
                  }
               },
               {
                  "$id":"24",
                  "FirstName":"Jonathan",
                  "LastName":"Harris",
                  "Protected":false,
                  "Sex":2,
                  "CreatedBy":"_JJB",
                  "CreatedOn":"2015-10-30T19:10:43",
                  "ModifiedBy":"_JJB",
                  "Id":"11a53145-ed1b-46c7-922b-1364985dafd9",
                  "ModifiedOn":"2018-03-12T21:21:02",
                  "Project":{
                     "$ref":"8"
                  }
               }
            ],
            "Edition":"15",
            "EvaluationComplexity":0,
            "EvaluationSourceTextFormat":0,
            "Groups":[

            ],
            "HasLabel1":false,
            "HasLabel2":false,
            "Keywords":[

            ],
            "Language":"eng",
            "LanguageCode":"en",
            "Locations":[
               {
                  "$id":"25",
                  "Address":{
                     "$id":"26",
                     "AttachmentFolderWasInFallbackMode":false,
                     "LinkedResourceStatus":8,
                     "OriginalString":"https://login.westlaw.co.uk/maf/wluk/app/tocectory?ao=o.I7F7C95A016F411E484DAA3644891B83B&ndd=2&sttype=stdtemplate&context=1";,
                     "LinkedResourceType":5,
                     "UriString":"https://login.westlaw.co.uk/maf/wluk/app/tocectory?ao=o.I7F7C95A016F411E484DAA3644891B83B&ndd=2&sttype=stdtemplate&context=1";,
                     "Properties":{

                     }
                  },
                  "Annotations":[

                  ],
                  "LocationType":0,
                  "MirrorsReferencePropertyId":151,
                  "CreatedBy":"_JJB",
                  "CreatedOn":"2016-08-20T12:12:27",
                  "ModifiedBy":"_JJB",
                  "Id":"33e132e7-4519-49c4-960f-1668e57f6661",
                  "ModifiedOn":"2018-03-12T21:21:07",
                  "Project":{
                     "$ref":"8"
                  }
               }
            ],
            "OnlineAddress":"https://login.westlaw.co.uk/maf/wluk/app/tocectory?ao=o.I7F7C95A016F411E484DAA3644891B83B&ndd=2&sttype=stdtemplate&context=1";,
            "Organizations":[

            ],
            "OriginalCheckedBy":"JJB, 2017-09-21",
            "OthersInvolved":[

            ],
            "PlaceOfPublication":"London",
            "Publishers":[
               {
                  "$id":"27",
                  "Name":"Sweet & Maxwell",
                  "Protected":false,
                  "CreatedBy":"_JJB",
                  "CreatedOn":"2015-08-03T15:41:46",
                  "ModifiedBy":"_JJB",
                  "Id":"239e3a79-cba6-4388-a7dc-9e5f2f56a670",
                  "ModifiedOn":"2018-03-12T21:21:02",
                  "Project":{
                     "$ref":"8"
                  }
               }
            ],
            "Quotations":[

            ],
            "ReferenceType":"BookEdited",
            "ShortTitle":"Collins & Harris, Dicey, Morris & Collins (2012)",
            "ShortTitleUpdateType":1,
            "SourceOfBibliographicInformation":"BibTeX",
            "StaticIds":[
               "be4515f8-bffe-419f-a1a0-ed89b599848c"
            ],
            "TableOfContentsComplexity":0,
            "TableOfContentsSourceTextFormat":0,
            "Tasks":[

            ],
            "Title":"Dicey, Morris and Collins on the conflict of laws",
            "Translators":[

            ],
            "Volume":"1",
            "Year":"2012",
            "YearResolved":"2012",
            "CreatedBy":"_JJB",
            "CreatedOn":"2015-10-30T19:11:21",
            "ModifiedBy":"_Jjbor",
            "Id":"92e5fc03-fa67-4b81-b52a-09d2ea4f8e52",
            "ModifiedOn":"2018-07-09T09:51:02",
            "Project":{
               "$ref":"8"
            }
         },
         "UseNumberingTypeOfParentDocument":false
      }
   ],
   "FormattedText":{
      "$id":"28",
      "Count":7,
      "TextUnits":[
         {
            "$id":"29",
            "FontStyle":{
               "$id":"30",
               "Neutral":true
            },
            "ReadingOrder":1,
            "Text":"Lawrence Collins, Baron Collins of Mapesbury & Jonathan Harris, eds, "
         },
         {
            "$id":"31",
            "FontStyle":{
               "$id":"32",
               "Italic":true
            },
            "ReadingOrder":1,
            "Text":"Dicey, Morris and Collins on the Conflict of Laws"
         },
         {
            "$id":"33",
            "FontStyle":{
               "$id":"34",
               "Neutral":true
            },
            "ReadingOrder":1,
            "Text":", 15th edn (London: Sweet & Maxwell, 2012), vol 1 at para 2.037; Jack Wass, ‘The Court's in Personam Jurisdiction in Cases Involving Foreign Land’ (2014) 63:1 "
         },
         {
            "$id":"35",
            "FontStyle":{
               "$id":"36",
               "Italic":true
            },
            "ReadingOrder":1,
            "Text":"International and Comparative Law Quarterly"
         },
         {
            "$id":"37",
            "FontStyle":{
               "$id":"38",
               "Neutral":true
            },
            "ReadingOrder":1,
            "Text":" 103 at 108–10; Tiong M Yeo, "
         },
         {
            "$id":"39",
            "FontStyle":{
               "$id":"40",
               "Italic":true
            },
            "ReadingOrder":1,
            "Text":"Choice of Law for Equitable Doctrines"
         },
         {
            "$id":"41",
            "FontStyle":{
               "$id":"42",
               "Neutral":true
            },
            "ReadingOrder":1,
            "Text":" (Oxford: Oxford University Press, 2004) at paras Intr.7-13"
         }
      ]
   },
   "Tag":"CitaviPlaceholder#b8b14b94-1712-4c40-8913-121438a7e26c",
   "Text":"Lawrence Collins, Baron Collins of Mapesbury & Jonathan Harris, eds, Dicey, Morris and Collins on the Conflict of Laws, 15th edn (London: Sweet & Maxwell, 2012), vol 1 at para 2.037; Jack Wass, ‘The Court's in Personam Jurisdiction in Cases Involving Foreign Land’ (2014) 63:1 International and Comparative Law Quarterly 103 at 108–10; Tiong M Yeo, Choice of Law for Equitable Doctrines (Oxford: Oxford University Press, 2004) at paras Intr.7-13",
   "WAIVersion":"6.1.0.0"
}

Foto
1

Ich habe gerade mal beide Merhfachnachweise in einem Online Parser eingegeben:

https://jsoneditoronline.org/?id=5d3ad65e115a4015b02f76dfed6306de

https://jsoneditoronline.org/?id=ac45977ad24b43e3a821d30e2682da79

Der letzte hat Kodierungsprobleme. Und das ist ein von Citavi erstellter Nachweis, oder? Oder haben wir aneinander vorbei geredet und der obere ist der von Citavi erstellte und der untere von deinem Makro?

Foto
1

Hmm, irgendeine Formatierungsfunktion des Forums führt dazu, dass der letztere Syntaxprobleme hat. Mit Kodierungsprobleme meinte ich, dass des Dekodierens des Base64-Felds eine andere Kodierung hat, als VBA erwartet – UTF8 statt UTF16. Ich bin aber auch in der Terminologie nicht so firm, irgendwie hängt es jedenfalls damit zusammen. Das lässt sich aber auch auffangen, genauso wie die wunderbare Vermehrung der Leerzeilen in den Seitenbereichen, auch wenn beides leider in noch mehr Hilfsfunktionen resultiert. Derzeit bin ich eigentlich nur damit beschäftigt, rauszukriegen, was das Muster ist, warum es bei manchen Mehrfachnachweisen funktioniert, bei anderen nicht.

Foto
Foto
2

Es macht Fortschritte. Folgendes Word-Makro verbindet Einzelnachweise in den einfachsten Fällen. Die Hauptänderung war, dass die ID-Neunummerierung im ursprünglichen Makro falsch war. In meinen Tests scheitert das Makro aber noch in komplexeren Fällen. Das ganze in Action gibt es hier zu sehen.


Sub CitaviMergeContentControls()

    ' Variables

    Dim selectedContentControlsCount As Long
    Dim contentControlIndex As Long
    
    Dim encodedPlaceholder As String
    Dim decodedPlaceholder As String
    
    Dim newPlaceholderEntries As String
    
    Dim formattedPlaceholders As String

    Dim newFormattedPlaceholderEntries As String
    Dim newFormattedPlaceholderBeginning As String
    Dim newFormattedPlaceholderEnd As String
    Dim newFormattedAndNumberedPlaceholder As String
        
    Dim newFormattedPlaceholder As String
    
    Dim newEncodedPlaceholder As String
    
    Dim newFieldCode As String
    
    Dim Json As Object
    
    ' The Magic
    
    Set selectedContentControls = Selection.ContentControls
    
    selectedContentControlsCount = selectedContentControls.Count
    
    i = 1

    For contentControlIndex = 1 To selectedContentControlsCount
    
        j = 1
    
        For Each Field In selectedContentControls(contentControlIndex).Range.Fields
            encodedPlaceholder = SuperMid(Field.Code, "{", "}")
            decodedPlaceholder = StrConv(DecodeBase64(encodedPlaceholder), vbUnicode)

            Set Json = JsonConverter.ParseJson(decodedPlaceholder)
            
            formattedPlaceholder = JsonConverter.ConvertToJson(Json, Whitespace:=2)
            
            formattedPlaceholders = formattedPlaceholders & formattedPlaceholder
            
            If i = 1 Then

                newFormattedPlaceholderBeginning = ExtractPlaceholderBeginning(formattedPlaceholders)
                newFormattedPlaceholderEnd = ExtractPlaceholderEnd(formattedPlaceholders)

            End If
            
            If j > 1 Then selectedContentControls(contentControlIndex).Range.Fields(j).Delete

            j = j + 1
            i = i + 1
        Next
    Next
    
    newFormattedPlaceholderEntries = ExtractPlaceholderEntries(formattedPlaceholders)
    
    newFormattedPlaceholder = newFormattedPlaceholderBeginning & newFormattedPlaceholderEntries & newFormattedPlaceholderEnd
    
    newFormattedAndNumberedPlaceholder = RenumberIDs(newFormattedPlaceholder)
    
    newPlaceholder = Replace(JsonConverter.ConvertToJson(JsonConverter.ParseJson(newFormattedAndNumberedPlaceholder), Whitespace:=0), vbCrLf, "")
    
    newEncodedPlaceholder = encodeBase64(StrConv(newPlaceholder, vbFromUnicode))
        
    newFieldCode = Replace("ADDIN CitaviPlaceholder{" & newEncodedPlaceholder & "}", vbLf, "")
    
    For contentControlIndex = 1 To selectedContentControlsCount
        If contentControlIndex = 1 Then
            selectedContentControls(contentControlIndex).Range.Fields(1).Code.Text = newFieldCode
        Else
            selectedContentControls(contentControlIndex).Delete True
        End If
    
    Next
      
End Sub

Private Function RenumberIDs(myString As String)

    Dim objRegExp As RegExp
    
    Set objRegExp = New RegExp
    
    i = 1

    With objRegExp
           .Pattern = "(" & Chr(34) & "\$id" & Chr(34) & ": " & Chr(34) & ")([0-9]+)(" & Chr(34) & ")"
           .Global = False
           .IgnoreCase = True
           .MultiLine = False
           Do While .Test(myString)
               Set objRegMC = .Execute(myString)
               For Each objRegM In objRegMC
                    
                    myString = .Replace(myString, Chr(34) & "$uniqueid" & Chr(34) & ": " & Chr(34) & i & "$3")
                    i = i + 1
               Next
           Loop
    End With
    
    With objRegExp
           .Pattern = "\$uniqueid"
           .Global = False
           .IgnoreCase = True
           .MultiLine = False
           Do While .Test(myString)
               Set objRegMC = .Execute(myString)
               For Each objRegM In objRegMC
                    myString = .Replace(myString, "$id")
               Next
           Loop
    End With
    
    RenumberIDs = myString
   
End Function


Private Function ExtractPlaceholderBeginning(myString As String)
   
    'Create objects.
    Dim objRegExp As RegExp
    Dim objMatch As Match
    Dim colMatches As matchCollection
    
    searchPattern = "^(\s*)([\S\s]+?)(\s*)(\n    {)"
    
    ' Create a regular expression object.
    Set objRegExp = New RegExp
    
    objRegExp.Pattern = searchPattern
    objRegExp.MultiLine = False
    objRegExp.IgnoreCase = True
    objRegExp.Global = False
    
    Set colMatches = objRegExp.Execute(myString)
    
    ExtractPlaceholderBeginning = colMatches(0).SubMatches(0) & colMatches(0).SubMatches(1) & colMatches(0).SubMatches(2)
   
End Function

Private Function ExtractPlaceholderEnd(myString As String)
   
    'Create objects.
    Dim objRegExp As RegExp
    Dim objMatch As Match
    Dim colMatches   As matchCollection
    Dim RetStr As String
    
    searchPattern = "(\n)(  ],)(\s*)([\S\s]+?)(\s*)$"
    
    ' Create a regular expression object.
    Set objRegExp = New RegExp
    
    objRegExp.Pattern = searchPattern
    objRegExp.MultiLine = False
    objRegExp.IgnoreCase = True
    objRegExp.Global = True
    
    Set colMatches = objRegExp.Execute(myString)
    ExtractPlaceholderEnd = colMatches(0).SubMatches(0) & colMatches(0).SubMatches(1) & colMatches(0).SubMatches(2) & colMatches(0).SubMatches(3)
   
End Function

Private Function ExtractPlaceholderEntries(myString As String)
   
    'Create objects.
    Dim objRegExp As RegExp
    Dim objMatch As Match
    Dim colMatches   As matchCollection
    Dim RetStr As String
    
    myPattern = "(\n    {)\s*([\S\s]+?)\s*(\n    })"
    
    ' Create a regular expression object.
    Set objRegExp = New RegExp
    
    objRegExp.Pattern = myPattern
    objRegExp.MultiLine = True
    objRegExp.IgnoreCase = True
    objRegExp.Global = True
    

    Set colMatches = objRegExp.Execute(myString)   ' Execute search.
    
    i = 1
        
    For Each objMatch In colMatches   ' Iterate Matches collection.
        If i < colMatches.Count Then
            RetStr = RetStr & objMatch.Value & ","
        Else
            RetStr = RetStr & objMatch.Value
        End If
        i = i + 1
    Next

    
    ExtractPlaceholderEntries = RetStr
   
End Function

Private Function DecodeBase64(ByVal strData As String) As Byte()
 
    Dim objXML As MSXML2.DOMDocument
    Dim objNode As MSXML2.IXMLDOMElement
    
    ' help from MSXML
    Set objXML = New MSXML2.DOMDocument
    Set objNode = objXML.createElement("b64")
    objNode.dataType = "bin.base64"
    objNode.Text = strData
    DecodeBase64 = objNode.nodeTypedValue
    
    ' thanks, bye
    Set objNode = Nothing
    Set objXML = Nothing
 
End Function

Private Function encodeBase64(ByRef arrData() As Byte) As String
    Dim objXML As MSXML2.DOMDocument
    Dim objNode As MSXML2.IXMLDOMElement
    
    Set objXML = New MSXML2.DOMDocument
    
    Set objNode = objXML.createElement("b64")
    objNode.dataType = "bin.base64"
    objNode.nodeTypedValue = arrData
    encodeBase64 = objNode.Text
 
    Set objNode = Nothing
    Set objXML = Nothing
End Function

Private Function SuperMid(ByVal strMain As String, str1 As String, str2 As String, Optional reverse As Boolean) As String
'DESCRIPTION: Extract the portion of a string between the two substrings defined in str1 and str2.
'DEVELOPER: Ryan Wells (wellsr.com)
'HOW TO USE: - Pass the argument your main string and the 2 strings you want to find in the main string.
' - This function will extract the values between the end of your first string and the beginning
' of your next string.
' - If the optional boolean "reverse" is true, an InStrRev search will occur to find the last
' instance of the substrings in your main string.
Dim i As Integer, j As Integer, temp As Variant
On Error GoTo errhandler:
If reverse = True Then
    i = InStrRev(strMain, str1)
    j = InStrRev(strMain, str2)
    If Abs(j - i) < Len(str1) Then j = InStrRev(strMain, str2, i)
    If i = j Then 'try to search 2nd half of string for unique match
        j = InStrRev(strMain, str2, i - 1)
    End If
Else
    i = InStr(1, strMain, str1)
    j = InStr(1, strMain, str2)
    If Abs(j - i) < Len(str1) Then j = InStr(i + Len(str1), strMain, str2)
    If i = j Then 'try to search 2nd half of string for unique match
        j = InStr(i + 1, strMain, str2)
    End If
End If
If i = 0 And j = 0 Then GoTo errhandler:
If j = 0 Then j = Len(strMain) + Len(str2) 'just to make it arbitrarily large
If i = 0 Then i = Len(strMain) + Len(str1) 'just to make it arbitrarily large
If i > j And j <> 0 Then 'swap order
    temp = j
    j = i
    i = temp
    temp = str2
    str2 = str1
    str1 = temp
End If
i = i + Len(str1)
SuperMid = Mid(strMain, i, j - i)
Exit Function
errhandler:
MsgBox "Error extracting strings. Check your input" & vbNewLine & vbNewLine & "Aborting", , "Strings not found"
End
End Function

Foto
1

Nicht schlecht, auch wenn der Code recht umfangreich (und damit potentiell fehleranfällig) aussieht.

Was genau wird da denn gemacht? Bei den JSONs sieht es auf den ersten Blick ja so aus, dass unter "Entries" einfach ein weiteres Element eingefügt wird? Oder kommen da noch weitere Sachen zu?


Vielleicht hat Citavi ja Interesse, das in etwa zu übernehmen gegen eine Bezahlung für deinen Aufwand?

Foto
1

Der geht alle Placeholder durch, filtert alle Entries raus, schreibt alle Entries in den ersten Placeholder, nummeriert die $ids neu sequentiell und löscht alle bis auf den Placeholder. Ich wüßte so spontan nicht, wie man das kürzer machen könnte, das Problem ist natürlich, dass es eine Menge Hilfsfunktionen benötigt, was den Code länger aussehen lässt. Operativ ist eigentlich nur die erste Funktion.

Foto
1

Ja, hab mir den Code in der Zwischenzeit genauer angesehen, auch wenn ich mit VBA noch nichts zu tun hatte.

Sah mit den ganzen Patterns und RegExps der Hilfsfunktionen komisch aus, aber die werden anscheinend ja nur zum Finden der Placeholder und nicht für die JSON Bearbeitung gebraucht.

Woran scheitert es denn noch bei komplexeren Dingen?

Foto
Foto
2

Folgender Code klappt bei mir jetzt gut, ich kann keine Probleme mehr finden, aber ich kann auch keine Garantie übernehmen. Wahrscheinlich ist das Nutzen der Felder-Reparieren-Funktion ab und an keine schlechte Idee. Die oberste Funktion macht die Arbeit, alle unteren sind Helfer. Dazu muss man noch die JSON-Komponenten importieren. Achso, und das ganze wird einfach in das erste Feld der ersten Content Control geschrieben, also gucken, das man nicht noch andere Content Controls markiert hat, welche nichts mit Citavi zu tun haben, oder zumindest nicht als erstes.


Das waren deutlich mehr als 90 Minuten diesmal, aber meiner Ansicht nach ist das hier eine essentielle Kernfunktion, die Citavi können müsste, zumindest wenn man die Wissenselementeidee ernst nimmt; was bringt mir das ganze schöne Strukturieren der Wissenselemente in Citavi, wenn ich danach die Wissenselemente nicht in einen Nachweis kombinieren kann?


Und kleiner Tipp am Rande: im Rahmen dieses Projektes bin ich ganz begeistert geworden von Atom. Toller Texteditor, mit dem ich immer wieder JSON-Objekte verglichen habe, um den Fehlern auf die Schliche zu kommen.


Sub CitaviMergeContentControls()
    Application.ScreenUpdating = False
    
    ' Variables

    Dim selectedContentControlsCount As Long
    Dim contentControlIndex As Long
    
    Dim encodedPlaceholder As String
    Dim decodedPlaceholder As String
    Dim formattedPlaceholder As String
    
    Dim firstFormattedPlaceholderBeginning As String
    Dim firstFormattedPlaceholderEnd As String
    Dim formattedPlaceholders As String
    
    Dim newPlaceholderEntries As String
    Dim newFormattedPlaceholderEntries As String
    
    Dim newFormattedPlaceholder As String
    Dim newFormattedAndNumberedPlaceholder As String
    Dim newPlaceholder As String
    Dim newEncodedPlaceholder As String
    Dim newFieldCode As String
    
    Dim Json As Object
    
    Dim i As Integer
    Dim j As Integer
    
    Dim selectedContentControls As ContentControls
    
    Set selectedContentControls = Selection.ContentControls
    selectedContentControlsCount = selectedContentControls.Count
    
    i = 1

    For contentControlIndex = 1 To selectedContentControlsCount
    
        j = 1
    
        For Each Field In selectedContentControls(contentControlIndex).Range.Fields
            If Field.Code Like "*ADDIN CitaviPlaceholder*" Then
                encodedPlaceholder = SuperMid(Field.Code, "{", "}")
                decodedPlaceholder = StrConv(DecodeBase64(encodedPlaceholder), vbUnicode)
                
                Set Json = JsonConverter.ParseJson(decodedPlaceholder)
                
                formattedPlaceholder = JsonConverter.ConvertToJson(Json, Whitespace:=2)
                
                formattedPlaceholder = UnescapeUTF8(formattedPlaceholder)
                
                If i = 1 Then
    
                    firstFormattedPlaceholderBeginning = ExtractPlaceholderBeginning(formattedPlaceholder)
                    firstFormattedPlaceholderEnd = ExtractPlaceholderEnd(formattedPlaceholder)
    
                End If
                
                formattedPlaceholders = formattedPlaceholders & formattedPlaceholder
                
                If j > 1 Then selectedContentControls(contentControlIndex).Range.Fields(j).Delete
    
                j = j + 1
                i = i + 1
            End If
        Next
    Next
    
    If Not Trim(formattedPlaceholders & vbNullString) = vbNullString Then
    
        newFormattedPlaceholderEntries = ExtractPlaceholderEntries(formattedPlaceholders)
        newFormattedPlaceholder = firstFormattedPlaceholderBeginning & newFormattedPlaceholderEntries & vbCr & firstFormattedPlaceholderEnd
        newFormattedAndNumberedPlaceholder = RenumberIDs(newFormattedPlaceholder)
        newFormattedAndNumberedPlaceholder = RedirectReferences(newFormattedAndNumberedPlaceholder)
        newPlaceholder = Replace(JsonConverter.ConvertToJson(JsonConverter.ParseJson(newFormattedAndNumberedPlaceholder), Whitespace:=0), vbCrLf, "")
        newPlaceholder = UnescapeUTF8(newPlaceholder)
        newPlaceholder = RemoveEscapedLineBreaks(newPlaceholder)
        newEncodedPlaceholder = encodeBase64(StrConv(newPlaceholder, vbFromUnicode))
        newFieldCode = Replace("ADDIN CitaviPlaceholder{" & newEncodedPlaceholder & "}", vbLf, "")
        
        i = 1
        
        For i = selectedContentControlsCount To 1 Step -1
            If i > 1 Then
                selectedContentControls(i).Delete
            End If
        Next
        
        selectedContentControls(1).Range.Fields(1).Code.Text = newFieldCode
        
    End If
    
    Application.ScreenUpdating = True
    
End Sub

Private Function RedirectReferences(myString As String)
    
    Dim objRegExp As RegExp
    Set objRegExp = New RegExp
    
    Dim objMatch As Match
    Dim colMatches As matchCollection
    
    Dim strProjectID As String
      
    objRegExp.Pattern = "(" & Chr(34) & "Project" & Chr(34) & ": {)([\s]+)(" & Chr(34) & "\$id" & Chr(34) & ": " & Chr(34) & ")([0-9]+)(" & Chr(34) & ")"
    objRegExp.MultiLine = False
    objRegExp.IgnoreCase = True
    objRegExp.Global = False
    
    Set colMatches = objRegExp.Execute(myString)
    strProjectID = colMatches(0).SubMatches(3)
    
        With objRegExp
           .Pattern = "(" & Chr(34) & "Project" & Chr(34) & ": {)([\s]+)(" & Chr(34) & "\$ref" & Chr(34) & ": " & Chr(34) & ")([0-9]+)(" & Chr(34) & ")"
           .Global = False
           .IgnoreCase = True
           .MultiLine = False
           Do While .Test(myString)
               Set objRegMC = .Execute(myString)
               For Each objRegM In objRegMC
                    myString = .Replace(myString, "$1$2" & Chr(34) & "$newref" & Chr(34) & ":  " & Chr(34) & strProjectID & "$5")
               Next
           Loop
    End With
    
    With objRegExp
           .Pattern = "\$newref"
           .Global = False
           .IgnoreCase = True
           .MultiLine = False
           Do While .Test(myString)
               Set objRegMC = .Execute(myString)
               For Each objRegM In objRegMC
                    myString = .Replace(myString, "$ref")
               Next
           Loop
    End With
    
    RedirectReferences = myString
End Function

Private Function RemoveEscapedLineBreaks(myString As String)
    
    Dim objRegExp As RegExp
    Set objRegExp = New RegExp

    With objRegExp
           .Pattern = "(^.?|(?!\\)..)(\\r|\\n)"
           .Global = False
           .IgnoreCase = True
           .MultiLine = False
           Do While .Test(myString)
               Set objRegMC = .Execute(myString)
               For Each objRegM In objRegMC
                    myString = .Replace(myString, "$1")
               Next
           Loop
    End With
    
    RemoveEscapedLineBreaks = myString

End Function

Private Function RenumberIDs(myString As String)

    Dim objRegExp As RegExp
    
    Set objRegExp = New RegExp
    
    i = 1

    With objRegExp
           .Pattern = "(" & Chr(34) & "\$id" & Chr(34) & ": " & Chr(34) & ")([0-9]+)(" & Chr(34) & ")"
           .Global = False
           .IgnoreCase = True
           .MultiLine = False
           Do While .Test(myString)
               Set objRegMC = .Execute(myString)
               For Each objRegM In objRegMC
                    myString = .Replace(myString, Chr(34) & "$uniqueid" & Chr(34) & ": " & Chr(34) & i & "$3")
                    i = i + 1
               Next
           Loop
    End With
    
    With objRegExp
           .Pattern = "\$uniqueid"
           .Global = False
           .IgnoreCase = True
           .MultiLine = False
           Do While .Test(myString)
               Set objRegMC = .Execute(myString)
               For Each objRegM In objRegMC
                    myString = .Replace(myString, "$id")
               Next
           Loop
    End With
    
    RenumberIDs = myString
   
End Function

Private Function ExtractPlaceholderBeginning(myString As String)

    Dim objRegExp As RegExp
    Set objRegExp = New RegExp
    
    Dim objMatch As Match
    Dim colMatches As matchCollection
      
    objRegExp.Pattern = "^(\s*)([\S\s]+?)(\s*)(\n    {)"
    objRegExp.MultiLine = False
    objRegExp.IgnoreCase = True
    objRegExp.Global = False
    
    Set colMatches = objRegExp.Execute(myString)
    
    ExtractPlaceholderBeginning = colMatches(0).SubMatches(0) & colMatches(0).SubMatches(1) & colMatches(0).SubMatches(2)
   
End Function

Private Function ExtractPlaceholderEnd(myString As String)

    Dim objRegExp As RegExp
    Set objRegExp = New RegExp
    
    Dim objMatch As Match
    Dim colMatches As matchCollection
      
    objRegExp.Pattern = "(\n)(  ],)(\s*)([\S\s]+?)(\s*)$"
    objRegExp.MultiLine = False
    objRegExp.IgnoreCase = True
    objRegExp.Global = False
    
    Set colMatches = objRegExp.Execute(myString)
    
    ExtractPlaceholderEnd = colMatches(0).SubMatches(0) & colMatches(0).SubMatches(1) & colMatches(0).SubMatches(2) & colMatches(0).SubMatches(3)
   
    ExtractPlaceholderEnd = colMatches(0).SubMatches(0) & colMatches(0).SubMatches(1) & colMatches(0).SubMatches(2) & colMatches(0).SubMatches(3)
   
End Function

Private Function ExtractPlaceholderEntries(myString As String)
   
    Dim objRegExp As RegExp
    Dim objMatch As Match
    Dim colMatches   As matchCollection
    Dim RetStr As String
    
    Set objRegExp = New RegExp
    
    objRegExp.Pattern = "(\n    {)\s*([\S\s]+?)\s*(\n    })"
    objRegExp.MultiLine = True
    objRegExp.IgnoreCase = True
    objRegExp.Global = True

    Set colMatches = objRegExp.Execute(myString)
    
    i = 1
        
    For Each objMatch In colMatches
        If i < colMatches.Count Then
            RetStr = RetStr & objMatch.Value & ","
        Else
            RetStr = RetStr & objMatch.Value
        End If
        i = i + 1
    Next

    
    ExtractPlaceholderEntries = RetStr
   
End Function

Private Function DecodeBase64(ByVal strData As String) As Byte()
 
    Dim objXML As MSXML2.DOMDocument
    Dim objNode As MSXML2.IXMLDOMElement
    
    Set objXML = New MSXML2.DOMDocument
    Set objNode = objXML.createElement("b64")
    objNode.dataType = "bin.base64"
    objNode.Text = strData
    DecodeBase64 = objNode.nodeTypedValue
    
    Set objNode = Nothing
    Set objXML = Nothing
 
End Function

Private Function encodeBase64(ByRef arrData() As Byte) As String
    Dim objXML As MSXML2.DOMDocument
    Dim objNode As MSXML2.IXMLDOMElement
    
    Set objXML = New MSXML2.DOMDocument
    
    Set objNode = objXML.createElement("b64")
    objNode.dataType = "bin.base64"
    objNode.nodeTypedValue = arrData
    encodeBase64 = objNode.Text
 
    Set objNode = Nothing
    Set objXML = Nothing
End Function

Private Function SuperMid(ByVal strMain As String, str1 As String, str2 As String, Optional reverse As Boolean) As String
    'DESCRIPTION: Extract the portion of a string between the two substrings defined in str1 and str2.
    'DEVELOPER: Ryan Wells (wellsr.com)
    'HOW TO USE: - Pass the argument your main string and the 2 strings you want to find in the main string.
    ' - This function will extract the values between the end of your first string and the beginning
    ' of your next string.
    ' - If the optional boolean "reverse" is true, an InStrRev search will occur to find the last
    ' instance of the substrings in your main string.
    Dim i As Integer, j As Integer, temp As Variant
    On Error GoTo errhandler:
    If reverse = True Then
        i = InStrRev(strMain, str1)
        j = InStrRev(strMain, str2)
        If Abs(j - i) < Len(str1) Then j = InStrRev(strMain, str2, i)
        If i = j Then 'try to search 2nd half of string for unique match
            j = InStrRev(strMain, str2, i - 1)
        End If
    Else
        i = InStr(1, strMain, str1)
        j = InStr(1, strMain, str2)
        If Abs(j - i) < Len(str1) Then j = InStr(i + Len(str1), strMain, str2)
        If i = j Then 'try to search 2nd half of string for unique match
            j = InStr(i + 1, strMain, str2)
        End If
    End If
    If i = 0 And j = 0 Then GoTo errhandler:
    If j = 0 Then j = Len(strMain) + Len(str2) 'just to make it arbitrarily large
    If i = 0 Then i = Len(strMain) + Len(str1) 'just to make it arbitrarily large
    If i > j And j <> 0 Then 'swap order
        temp = j
        j = i
        i = temp
        temp = str2
        str2 = str1
        str1 = temp
    End If
    i = i + Len(str1)
    SuperMid = Mid(strMain, i, j - i)
    Exit Function
errhandler:
    MsgBox "Error extracting strings. Check your input" & vbNewLine & vbNewLine & "Aborting", , "Strings not found"
    End
End Function

'modified from http://needtec.sakura.ne.jp/codeviewer/index.php?id=2
'https://gist.github.com/yadimon/ce1d04b88de17064bfae

Private Function UnescapeUTF8(ByVal StringToDecode As String) As String
    Dim i As Long
    Dim acode As Integer, sTmp As String
    
    On Error Resume Next
    
    If InStr(1, StringToDecode, "\") = 0 And InStr(1, StringToDecode, "%") = 0 Then
        UnescapeUTF8 = StringToDecode
        Exit Function
    End If
    For i = Len(StringToDecode) To 1 Step -1
        acode = Asc(Mid$(StringToDecode, i, 1))
        Select Case acode
        Case 48 To 57, 65 To 90, 97 To 122
            ' don't touch alphanumeric chars
            DoEvents

        Case 92, 37: ' Decode \ or % value with uXXXX format
            If Mid$(StringToDecode, i + 1, 1) = "u" Then
                sTmp = CStr(CLng("&H" & Mid$(StringToDecode, i + 2, 4)))
                If IsNumeric(sTmp) Then
                    StringToDecode = Left$(StringToDecode, i - 1) & ChrW$(CInt("&H" & Mid$(StringToDecode, i + 2, 4))) & Mid$(StringToDecode, i + 6)
                End If
            End If
            
        Case 37: ' % not %uXXXX but %XX format
            
            sTmp = CStr(CLng("&H" & Mid$(StringToDecode, i + 1, 2)))
            If IsNumeric(sTmp) Then
                StringToDecode = Left$(StringToDecode, i - 1) & ChrW$(CInt("&H" & Mid$(StringToDecode, i + 1, 2))) & Mid$(StringToDecode, i + 3)
            End If
            
        End Select
    Next

    UnescapeUTF8 = StringToDecode
End Function

Foto
1

Vielen Dank für die Arbeit! Vielleicht klappt es ja sogar, die irgendwie in Citavi aufzunehmen, zumindest gibt es ja schonmal die Rückmeldung von Peter.


Atom kannte ich schon und nutze ich auch öfters mal, weil er schön schlank ist.

Foto
Foto
2

Hallo JJ

Ich frage den Vater des Word Add-ins nach seiner Rückkehr aus seinem Urlaub, wie er dazu steht.

Freundliche Grüsse

Peter