vbscript-create-a-blank-workbook

VBScript - Create A Blank Workbook

This script file allows you to create a blank MS Excel workbook.

VBScript

  • 364
  • 200
  • 0
  • 0
Add to collection
© VBAmacros.net2020

1 Open your favorite text editor. In our case we are going to use Notepad++

2 Copy the VBScript code from below.

3 Paste the code in the newly created file.


4 Save the file with a ".vbs" extension.

5 Run the script file by double-clicking on it or via the CMD console.

6 That's it!


Advertisement

Code
' This script creates a blank MS Excel workbook.
Sub createBlankExcelWorkbook()
	' Set variables
	Dim appExcel
	' Create new excel application object
	Set appExcel = Wscript.CreateObject("Excel.Application")
	' Set it to be visible
	appExcel.Visible = True
	' Add a new workbook
	appExcel.Workbooks.Add
	' Set first sheet name
	appExcel.Sheets(1).Name = "My Worksheet"
	' Select the worksheet
	appExcel.Sheets(1).Select
	' Release the excel application object
	Set appExcel = Nothing
End Sub
' Run the procedure
Call createBlankExcelWorkbook()
Advertisement


Comments
Sort by:
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
VBAmacros.net VBAmacros.net
Code was successfully copied!
VBAmacros.net VBAmacros.net
Please sign in!
VBAmacros.net VBAmacros.net
You've already voted!