Last active
June 2, 2023 13:02
-
-
Save simply-coded/2410f59e198019e7d598221abc476c1b to your computer and use it in GitHub Desktop.
Converts your clipboard data into a multiline string made for vbscript. Makes it easy to create other coding files within your vbscript file. Video demo available on YouTube.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'*********************** | |
'Name: String Formatter | |
'Author: Jeremy England | |
'Company: SimplyCoded | |
'Version: rev.001 | |
'Date: 04/08/2016 | |
'*********************** | |
Option Explicit | |
Dim htm : Set htm = CreateObject("htmlfile") | |
Dim wsh : Set wsh = CreateObject("wscript.shell") | |
Dim fso : Set fso = CreateObject("scripting.filesystemobject") | |
Dim data, words, w, lines, l | |
Dim multiline, tmp, info, countChars | |
info = MsgBox("Copy the text or code you wish to format into a multiline string. Then click [OK].",vbInformation+vbOKCancel,"VBScript Multiline String Formatter:") | |
If info = vbCancel Then | |
WScript.Quit | |
End If | |
data = htm.ParentWindow.ClipboardData.GetData("Text") | |
If Not TypeName(data) = "String" Or data = "" Then | |
MsgBox "Invalid clipboard text.", vbCritical | |
WScript.Quit | |
Else | |
data = Replace(data, """", """""") | |
End If | |
multiline = """" | |
If InStr(data, vbCrLf) Then | |
lines = Split(data, vbCrLf) | |
For l = 0 To UBound(lines) | |
If l = UBound(lines) Then | |
multiline = multiline & lines(l) & """" | |
Else | |
multiline = multiline & lines(l) & """ &vbCrLf&_" & vbCrLf & """" | |
End If | |
Next | |
Else | |
words = Split(data, " ") | |
For w = 0 To UBound(words) | |
If w Mod 10 = 0 Then | |
multiline = multiline & words(w) & """ &_" & vbCrLf & """" | |
Else | |
multiline = multiline & words(w) & " " | |
End If | |
Next | |
multiline = multiline & """" | |
End If | |
tmp = fso.GetSpecialFolder(2) & "\" & fso.GetTempName() | |
With fso.CreateTextFile(tmp, True, 2) | |
.Write multiline | |
.Close | |
End With | |
wsh.Run "notepad.exe " & tmp, 1, True | |
fso.DeleteFile tmp, True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Touch and hold a clip to pin it. Unpinned clips will be deleted after 1 hour.
How to get https