excel vba - Trying to save sheet 2 of a workbook on the desktop as CSV -


this function, when clicked on should ideally copy of worksheet 2 workbook , save sheet csv file. not working... , don't know how tell save file (i want save desktop). please?

is there easier way can this?

private sub commandbutton2_click()   'save csv'  fname = "cambs_uploader.csv" sheet2.saveas fname, xlcsv   end sub 

if it's simple saving desktop every time can put full path in string, rather file name. however, if want save selection directory tree, easiest way in excel use application.getsaveasfilename() method.

documentation: http://msdn.microsoft.com/en-us/library/office/ff195734.aspx

example:

sub commandbutton2_click()    dim fname string    dim savesheet worksheet     set savesheet = activeworkbook.sheets("sheet2") ' change sheet name     savesheet.saveas application.getsaveasfilename("cambs_uploader.csv", ".csv", 1, "save file")     set savesheet = nothing exit sub 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -