excel vba - Move VBA code to standalone VBS file -


i have macro in excel vba runs shell execute simple pdf editor command line, exports list of page names , numbers, searches keyword find page want, gets page num, , extracts page pdf file.

i've realised macro serve better standalone entity, , wondering required take code out of excel, , run .vbs file.

i tried direct copy , paste , didnt letter "a" in word "as" in first line.

sub pdf_getufplan()  dim wsh object set wsh = vba.createobject("wscript.shell") dim waitonreturn boolean: waitonreturn = true dim windowstyle integer: windowstyle = 1 dim errorcode integer  wsh.run "c:\users\johnmcs\desktop\pdftk.exe c:\users\johnmcs\desktop\full.pdf burst output c:\users\johnmcs\desktop\output.txt", windowstyle, waitonreturn  dim hf integer: hf = freefile dim lines() string, long  open "c:\users\johnmcs\desktop\doc_data.txt" input #hf     lines = split(input$(lof(hf), #hf), vbnewline)  close #hf  = 0 ubound(lines)  if instrrev(lines(i), "upper floor plan") > 0  x = ubound(lines)     if instrrev(lines(x), "bookmarkpagenumber: ") > 0      dim ufpagenum integer, pagenumposi integer     pagenumposi = instrrev(lines(x), " ")       pagenumposi = len(lines(x)) - pagenumposi      ufpagenum = right(lines(x), pagenumposi)      goto extractpage      end if  next   end if debug.print "line"; i; "="; lines(i) next    extractpage:  wsh.run "c:\users\johnmcs\desktop\pdftk.exe c:\users\johnmcs\desktop\full.pdf cat " & ufpagenum & " output c:\users\johnmcs\desktop\page" & ufpagenum & ".pdf", windowstyle, waitonreturn    end sub 

sub pdf_getufplan()  dim wsh  set wsh = createobject("wscript.shell") ' nb have wscript.createobject dim waitonreturn  waitonreturn = true dim windowstyle  windowstyle = 1 dim errorcode  

so here, beginning fixed. cannot dim anything. variant. must late bound sets must done createobject - no set x = new thing set x = createobject("thing.application").

remember vb6/vba supports vbs feature set. vbs compatable (a design goal) vb6/vba.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -