Option Explicit ' rg_PasteAsFile.vbs Ver 1.25, Rick G. ' Reference: http://my.noteworthysoftware.com/?topic=7088.0 Const f = "Clipboard.nwctxt", NWC = "!NoteWorthyComposer" Dim a, e, s: a = Array("", 0) If WScript.Arguments.Named.Exists("copyall") Then ' added Ver 1.10 CreateObject("WScript.Shell").SendKeys "^a^c" ElseIf WScript.Arguments.Named.Exists("copy") Then CreateObject("WScript.Shell").SendKeys "^c" End if e = CreateObject("htmlfile").parentWindow.clipboardData.getData("text") If IsNull(e) Then e = "" ' empty? For Each e In Split(e, vbCrLf) e = LTrim(e) ' rarely needed If Left(e, 35) = NWC & "Clip(2.0,Single)" Or _ Left(e, 35) = NWC & "Clip(2.5,Single)" Then ' begin ClipTxt a = Array("|AddStaff" & vbCrLf, 1) ElseIf Left(e, 27) = NWC & "Clip-End" Then If a(1) = 1 Then s = s & a(0) a = Array("", 0) ElseIf Left(e, 24) = NWC & "(2.0)" Or _ Left(e, 24) = NWC & "(2.5)" Then ' begin nwctxt a = Array("", 2) ElseIf Left(e, 23) = NWC & "-End" Then If a(1) = 2 Then s = s & a(0) a = Array("", 0) ElseIf a(1) Then ' in Clip(1) or nwctxt(2) If Left(e, 1) = "|" Then If Left(e, 5) = "|Fake" Then ElseIf Left(e, 8) = "|Context" Then Else a(0) = a(0) & e & vbCrLf End If ElseIf Left(e, 1) = "#" Then If InStr(1, e, " layer", 1) Then a(0) = a(0) & "|StaffProperties|Layer:Y|" & vbCrLf End If End If End If Next If s = "" Then ' unbalancd tags or no tags WScript.Echo "No data in Clipboard." Else ' write (or overwrite) nwctxt file With CreateObject("Scripting.FileSystemObject").CreateTextFile(f, 1) .WriteLine NWC & "(2.0)" & vbCrLf & s & NWC & "-End" .Close ' causes pause until write is complete End With CreateObject("WScript.Shell").Run Chr(34) & f & Chr(34) End If