excel vba - How to open and display text file at specific line from VBA -


i have vba userform handy open associated text file in textpad. can achieve following:

call shell("c:\program files\textpad 5\textpad.exe " & "c:\testfile.txt", vbnormalfocus) 

however, i'd have text file displayed @ specific line number. there way pass line number argument shell call? i'm @ loss here.

you can accomplish using wscript.shell.sendkeys trigger goto line shortcut within textpad (ctrl-g)

dim wshshell set wshshell = createobject("wscript.shell")  call shell("c:\program files\textpad 5\textpad.exe " & "c:\testfile.txt", vbnormalfocus) application.wait (10) wshshell.sendkeys "^g"      'ctrl-g application.wait (10) wshshell.sendkeys "15"      'desired line number application.wait (10) wshshell.sendkeys "{enter}" 'enter 

you might have mess wait lines add or remove delays between commands, tested within vba module in excel , worked.

i aware sendkeys can called directly vba, when tried use that, seems bound vba editor window.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -