vba - Open an Excel file, run a macro, save it (overwrite) -


i'm trying create .vbs

  1. opens excel
  2. runs macro
  3. saves new information
  4. quits

this have far:

dim xlapp, xlbook  set xlapp = createobject("excel.application") xlapp.displayalerts = false  set xlbook = xlapp.workbooks.open("c:\test\test.xlsm", 0, true)   xlapp.run "test" xlbook.save xlbook.close false set xlbook = nothing  xlapp.quit set xlapp = nothing  wscript.echo "upload finished" wscript.quit 

i 'upload finished', macro not saved. doing wrong?

the macro putting 1 worksheet another:

sub test() ' ' test macro '     sheets("sheet2").select     range("a1:a10").select     range("a10").activate     selection.cut     activesheet.previous.select     selection.end(xltoleft).select     range("a2").select     activesheet.paste end sub 

out of curiosity why macro in excel? if controlling excel via object, why not have macro code in there also?

dim xlapp, xlbook  set xlapp = createobject("excel.application") xlapp.displayalerts = false  set xlbook = xlapp.workbooks.open("c:\test\test.xlsm", 0, true)   xlbook.sheets("sheet2").range("a1:a10").cut xlbook.sheets("sheet2").previous.select xlbook.range("a2").paste xlbook.save xlbook.close false set xlbook = nothing  xlapp.quit set xlapp = nothing  wscript.echo "upload finished" wscript.quit 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -