Disable clipboard prompt in Excel VBA on workbook close -
i have excel workbook, using vba code opens workbook, copies data original, closes second workbook.
when close second workbook (using application.close
), prompt for:
do want save clipboard.
is there command in vba bypass prompt?
i can offer 2 options
- direct copy
based on description i'm guessing doing
set wb2 = application.workbooks.open("yourfile.xls") wb2.sheets("yoursheet").[<yourrange>].copy thisworkbook.sheets("somesheet").paste wb2.close
if case, don't need copy via clipboard. method copies source destination directly. no data in clipboard = no prompt
set wb2 = application.workbooks.open("yourfile.xls") wb2.sheets("yoursheet").[<yourrange>].copy thisworkbook.sheets("somesheet").cells(<yourcell") wb2.close
- suppress prompt
you can prevent alert pop-ups setting
application.displayalerts = false
[edit]
- to copy values only: don't use copy/paste @ all
dim rsrc range dim rdst range set rsrc = wb2.sheets("yoursheet").range("yourrange") set rdst = thisworkbook.sheets("somesheet").cells("yourcell").resize(rsrc.rows.count, rsrc.columns.count) rdst = rsrc.value
Comments
Post a Comment