argument
Sub MainMacro()
' Get large input text from the user
Dim bulkData As String
bulkData = GetLargeInput("Paste your bulk data below:")
' Example: Display the first 500 characters of the input to confirm
MsgBox "You entered: " & Left(bulkData, 500) & vbCrLf & vbCrLf & "Total length: " & Len(bulkData)
End Sub
Function GetLargeInput(prompt As String) As String
Dim tempFile As String
Dim fileNum As Integer
Dim userInput As String
' Create a temporary text file in the user's temp folder
tempFile = Environ("TEMP") & "\LargeInput.txt"
' Open Notepad with the temp file
Shell "notepad.exe " & tempFile, vbNormalFocus
MsgBox "Please paste your large text into Notepad and save it (Ctrl+S), then close Notepad. Click OK when done.", vbInformation
' Wait until user closes Notepad
Do While FileLocked(tempFile)
DoEvents
Loop
' Read the file content
fileNum = FreeFile
Open tempFile For Input As #fileNum
userInput = Input$(LOF(fileNum), #fileNum)
Close #fileNum
' Delete the temp file
Kill tempFile
' Return the data
GetLargeInput = userInput
End Function
Function FileLocked(filename As String) As Boolean
On Error Resume Next
Dim fileNum As Integer
fileNum = FreeFile
Open filename For Binary Access Read Write Lock Read Write As #fileNum
Close fileNum
If Err.Number <> 0 Then
FileLocked = True
Err.Clear
Else
FileLocked = False
End If
On Error GoTo 0
End Function
Comments
Post a Comment