vba - VBS crashing excel -


i have 4 macros:

1) thisworkbook.turn_off_alerts: turns off excel alerts
2) refresh_base: updates data sql connection
3) refresh_pivot: refreshes pivot table base data , saves workbook.
4) send_range_or_whole_worksheet_with_mailenvelope: emails pivot table group of users

each of these runs fine individually, simplify little, created

run_all calls these 4 macros in order. copied vbs file online run report, when execute it, "microsoft excel has stopped working" message , finished message, email did not send , file not saved. here code using:

     option explicit       dim xlapp, xlbook       set xlapp = createobject("excel.application")      set xlbook = xlapp.workbooks.open("y:\overrides expiring in next 30 days.xlsm", 0, true)      xlapp.run "run_all"      xlbook.close      xlapp.quit       set xlbook = nothing      set xlapp = nothing       wscript.echo "finished."      wscript.quit 

edit: macro breaking it. works in excel though.

     sub send_range_or_whole_worksheet_with_mailenvelope()      'working in excel 2002-2013      'declare string variable recipient list, , integer         variable      'for count of cells in column contain email addresses.      dim strto string      dim integer  dim aworksheet worksheet dim sendrng range dim rng range  on error goto stopmacro  application     .screenupdating = false     .enableevents = false end  'fill in worksheet/range want mail 'note: if use 1 cell send whole worksheet set sendrng = worksheets("pivot").range("a1:b15")  'remember activesheet set aworksheet = activesheet  sendrng      ' select worksheet range want send     .parent.select      'remember activecell on worksheet     set rng = activecell      'select range want mail     .select      ' create mail , send     activeworkbook.envelopevisible = true     .parent.mailenvelope          ' set optional introduction field thats adds         ' header text email body.         .introduction = "all, have attached list of overrides expiring within next 30 days. automated message, refreshing every 3 weeks, if need report update in absence please go y:\reports\ltomacro.vbs . thank you"          .item             .to = "myemail@email.com"             .cc = ""             .bcc = ""             .subject = "leadtime overrides expiring 30 days"             .attachments.add activeworkbook.fullname             .send         end      end      'select original activecell     rng.select end  'activate sheet active before run macro aworksheet.select  stopmacro: application     .screenupdating = true     .enableevents = true end activeworkbook.envelopevisible = false  end sub 


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -