vba - How to make a command button in word open a file using VB -
so basically, opened microsoft word , went developer tab, drew command button, double clicked open vb write code, want open specific file. code wrote
does not work...
my code got far is
private sub commandbutton1_click() process.start ("c:\program files\google\chrome\application\chrome.exe") end sub when click run comes error saying:
run-time error '424': object required can please fix me because have no idea... need 1 button , that's all.
ok need friend...
create new module - if don't have one:
- to - done in visual basic
- then, press: alt > select: insert (menu) > select: module
- note: can change module name via properties window - example left default 'module1'
write public sub (as below):
public sub startexewithargument() dim strprogramname string dim strargument string strprogramname = "c:\program files (x86)\google\chrome\application\chrome.exe" strargument = "/g" call shell("""" & strprogramname & """ """ & strargument & """", vbnormalfocus) end subcall sub in click command private sub:
private sub commandbutton1_click() module1.startexewithargument end sub
ok, enjoy ;)
Comments
Post a Comment