excel vba - Access Saving a Macro-Enabled Spreadsheet, ERROR -


i trying access open macro-enabled file macro-enabled template, fill in data save it.

i keep getting following errors: 1- excel template hidden using application.visible = false in thisworkbook section

this error message displays

2- if click yes make macro-free workbook following run-time error yes-runtime error

3- if click no run-time error no-runtime error

this code using:

workorder = me.txtworkorder & "_" & me.txtactorder  set xlapp = new excel.application  xlapp.visible = false excel.application.enableevents = false  set wb = xlapp.workbooks.open("h:\template , testers\template\tablettemplate.xltm") set ws = xlapp.worksheets("profile")  ws.activate     if me.txtworkocheck = 1         'workorder         ws             .range("b1") = me.txtworkorder             .range("b2") = me.txtuserid             .range("b3") = me.txtjobsiteid             .range("b4") = me.cboplant.value             .range("b5") = me.cboarea.value             .range("b6") = me.txtscaffoldid             .range("b7") = me.txtactorder             .range("b10") = output             .range("b11") = me.txtfunclocation          end     else         'sub-workorder         ws             .range("b8") = me.txtworkorder             .range("b2") = me.txtuserid             .range("b3") = me.txtjobsiteid             .range("b4") = me.cboplant.value             .range("b5") = me.cboarea.value             .range("b6") = me.txtscaffoldid             .range("b9") = me.txtactorder             .range("b1") = me.txtassoworkorder             .range("b10") = output             .range("b11") = me.txtfunclocation             .range("f1") = 0         end     end if  xlapp.worksheets("scaffoldlist").activate wb.saveas ("h:\activeworkorders\togather\" & workorder & ".xlsm") excel.application.enableevents = true  wb.close set xlapp = nothing 

everything works until code gets saveas... not sure how fix one.

you need specify type you're saving as, specifying extension isn't enough.

replace line giving error following:

wb.saveas "h:\activeworkorders\togather\" & workorder & ".xlsm", xlopenxmlworkbookmacroenabled

see this msdn page documentation on saveas method


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -