PDA

View Full Version : Use VBA to output file automatically



Notsure
07-29-2015, 06:26 AM
I have a numerical control that runs off windows and there's a program in the control that records all the key strokes that an operator presses. The only way to extract the recorded key strokes is by manually standing at the control and pressing F6 to "OutPut" file, which creates a .txt file, that gets put on the D-drive. I was told that with a little creativity using VB, I might be able to get the file to automatically get output. Since the machine is hooked up to a network, I'd like to be able to view this txt file from another location without having to be at the machine. The file name is called: DH*Y*M*D.TXT, is there a VB program or format that i can follw in order to extract this file automatically?

jonh
07-30-2015, 02:52 AM
I wouldn't normally recommend Sendkeys but if you want to try it...

Save to a text file, give it a .hta extension and run it on the same computer that runs the 'control'.


<html><head><HTA:APPLICATION
APPLICATIONNAME="KeySender"
SCROLL="no"
SINGLEINSTANCE="yes"
SHOWINTASKBAR="no"
CONTEXTMENU = "no"
CAPTION="no"
SELECTION="no">
<script language="vbscript">
dim WshShell
set WshShell = CreateObject("WScript.Shell")
Sub Window_Onload
self.ResizeTo 100, 80
WshShell.sendkeys "{F6}" 'send F6 key
setTimeout "Window_Onload", 1000 *60 'every 1 minute
end sub
</script></head><body>
<button onclick="window.close">Quit</button>
</body></html>