VBA 7. Adding, Saving & closing Workbooks

Dim newWB As Workbook


Set newWB = Workbooks.Add  'to add new workbook

newWB.SaveAs Filename:="D:\newWB.xlsx"   ' to save new workbook


OPEN A WORKBOOK
dim wb as workbook
set wb=Workbooks.open                'open new workbook
FilePath = "D:\newWB.xlsx"
Set wb = Workbooks.Open(FilePath)  'open workbook with path
wb.Close savechanges:=False        'close workbook without savings chanegs
 or

wb.Close savechanges:=true

 

 

 

Leave a Reply