![]() |
KnowBrainer Speech Recognition | ![]() |
Topic Title: FileSystemObjects Topic Summary: What, if anything, should be here⦠Created On: 05/19/2022 04:18 PM Status: Post and Reply |
|
![]() |
![]() |
- GarethR | - 05/19/2022 04:18 PM |
![]() |
![]() |
- GarethR | - 05/19/2022 04:22 PM |
![]() |
![]() |
- Lunis Orcutt | - 05/19/2022 08:11 PM |
![]() |
![]() |
- Todd | - 05/20/2022 12:47 AM |
![]() |
![]() |
- GarethR | - 05/20/2022 11:58 AM |
![]() |
|
I have a command that lets me cut, copy and paste from three files kept in my C drive. here are two snippets from it… Dim oFSO As New FileSystemObject Dim oFS ... Case "Paste" Select Case ListVar2 Case "one" Set oFS = oFSO.OpenTextFile("C:\ProgramData\Clip1.txt") Do Until oFS.AtEndOfStream sText = oFS.ReadLine Loop Clipboard sText SendSystemKeys "{Ctrl+v}" so what, if anything should be after "Dim oFS"? it still works, but I'd like to know please. Cheers, Gareth
------------------------- DPI 15.61 | Plantronics D100 | Windows 10 Home | Intel(R) Core(TM) i5-10210U CPU 1.60GHz |
|
|
|
![]() |
|
Perhaps this would be best in Commands, Scripts, and Macros - Dragon, if those with power can move it?
------------------------- DPI 15.61 | Plantronics D100 | Windows 10 Home | Intel(R) Core(TM) i5-10210U CPU 1.60GHz |
|
|
|
![]() |
|
Done ------------------------- Change "No" to "Know" w/KnowBrainer 2020 |
|
|
|
![]() |
|
By default, oFS will be declared as a variant. This will work, but you might want to declare it as a generic object:
Dim oFS as Object
If your code works, then you probably already referenced "Microsoft Scripting Runtime (1.0)". Finally, it looks like you will need to rework the logic for sText as it appears to simply store the last line read. The following code appears to work should you wish to integrate it into your existing script.
'#Language "WWB-COM"
Option Explicit
Sub Main Dim oFSO As FileSystemObject Dim oFS As Object Dim sText As String
sText = ""
Set oFSO = CreateObject("Scripting.FileSystemObject") Set oFS = oFSO.OpenTextFile("C:\ProgramData\Clip1.txt")
Do Until oFS.AtEndOfStream sText = sText & oFS.ReadLine Loop
Clipboard sText End Sub
I hope you find this helpful. ------------------------- Todd Kermit |
|
|
|
![]() |
|
Very much so, thank you. I didn't have that reference at the top, but have added it. Up till now, I relied on the main clipboard for multiple line copies, and use clipboard 1-3 for single line words, phrases, code…
Thanks again. Maybe others have better versions, especially the software people have developed, but here is my command, after updating, if anybody else is interested in it. '#Language "WWB-COM" Option Explicit Sub Main Dim oFSO As New FileSystemObject Dim oFS As Object Dim sText As String Dim CBMaster As String On Error Resume Next CBMaster = Clipboard Select Case ListVar1 Case "Copy" Select Case ListVar2 Case "one" SendSystemKeys "{Ctrl+c}" Set oFS = oFSO.CreateTextFile("C:\ProgramData\Clip1.txt", True) oFS.Write(Clipboard) Case "two" SendSystemKeys "{Ctrl+c}" Set oFS = oFSO.CreateTextFile("C:\ProgramData\Clip2.txt", True) oFS.Write(Clipboard) Case "three" SendSystemKeys "{Ctrl+c}" Set oFS = oFSO.CreateTextFile("C:\ProgramData\Clip3.txt", True) oFS.Write(Clipboard) End Select Case "Paste" Select Case ListVar2 Case "one" Set oFS = oFSO.OpenTextFile("C:\ProgramData\Clip1.txt") Do Until oFS.AtEndOfStream sText = sText & oFS.ReadLine & vbNewLine Loop Clipboard sText SendSystemKeys "{Ctrl+v}" Case "two" Set oFS = oFSO.OpenTextFile("C:\ProgramData\Clip2.txt") Do Until oFS.AtEndOfStream sText = sText & oFS.ReadLine & vbNewLine Loop Clipboard sText SendSystemKeys "{Ctrl+v}" Case "three" Set oFS = oFSO.OpenTextFile("C:\ProgramData\Clip3.txt") Do Until oFS.AtEndOfStream sText = sText & oFS.ReadLine & vbNewLine Loop Clipboard sText SendSystemKeys "{Ctrl+v}" End Select Case "Cut" Select Case ListVar2 Case "one" SendSystemKeys "{Ctrl+x}" Set oFS = oFSO.CreateTextFile("C:\ProgramData\Clip1.txt", True) oFS.Write(Clipboard) Case "two" SendSystemKeys "{Ctrl+x}" Set oFS = oFSO.CreateTextFile("C:\ProgramData\Clip2.txt", True) oFS.Write(Clipboard) Case "three" SendSystemKeys "{Ctrl+x}" Set oFS = oFSO.CreateTextFile("C:\ProgramData\Clip3.txt", True) oFS.Write(Clipboard) End Select End Select Clipboard CBMaster If Err.Number <> 0 Then Beep End If End Sub ------------------------- DPI 15.61 | Plantronics D100 | Windows 10 Home | Intel(R) Core(TM) i5-10210U CPU 1.60GHz |
|
|
FuseTalk Standard Edition v4.0 - © 1999-2022 FuseTalk™ Inc. All rights reserved.