Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Contact us
Hide Buttons

VBA-Excel: Create a WorkBook at Runtime.

Using VBA (Visual Basic for Appli­ca­tions) , you can cre­ate Excel work­book at the run­time by using Add() method.

If you won’t pro­vide any name for the work­book it will be cre­ated as BookN, where N will increase auto­mat­i­cally, start­ing from 0, as you call WorkBook.Add() function.


Function FnCreateWorkBook()

         Dim objWorkBook As Workbook

         Set objWorkBook = Workbooks.Add

         objWorkBook.SaveAs Filename:="NewWorkBook.xls"

End Function

.Add() method cre­ates a work­book and return object of the that. Later on you can use that object to save it to spe­cific loca­tion or other operations.



You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: