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...

  1. 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'
  2. 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 sub 
  3. call sub in click command private sub:

    private sub commandbutton1_click()     module1.startexewithargument end sub 

ok, enjoy ;)


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -