0 votes
in VBA by Beginner (26 points)
I want to know if it's possible to show a msgbox once I start Windows (not Excel) containing some calculations and reminders regarding the date change.

2 Answers

+2 votes
by Super Expert (1.9k points)
selected by
Best answer

You can launch a msgbox using VBscript by placing the MsgBox call statement directly in a .vbs file. For example, to remind a user that their clock will be changing soon, create a file called TimeChange.vbs (or whatever other file name you want with a .vbs extension. Enter the following code in the file:

if now < CDate("03-10-19 02:00:00") then
    msgbox "Your clock will change in " & DateDiff("h", now, "03-10-2019 02:00:00") & " hours."
end if

You can either place the file in the startup folder of the computer, or schedule it to run with the Task Scheduler. The files in the startup folder run each time Windows starts. 

  • The default startup location for Windows 10 is
    • C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp
  • The default startup folder for Windows 7 is
    • C:\Program Data\Microsoft\Windows\Start Menu\Programs\Startup


+1 vote
by Skilled (401 points)
edited by

Hello Abdan

You can run VBA macro through VBS file using task scheduler. Follow these steps

First create Sample.xlsm file and insert a macro named "Test" and put the message box in the macro

Sub Test()
    MsgBox "Hello World", 64
End Sub

Then create the VBS file and name it "RunMe" with this code

Set fso = CreateObject("Scripting.FileSystemObject")
curDir = fso.GetAbsolutePathName(".")

Set myxlApplication = CreateObject("Excel.Application")
myxlApplication.Visible = False
Set myWorkBook = myxlApplication.Workbooks.Open( "C:\Users\Future\Desktop\Sample.xlsm" )
myWorkBook.Application.Run "Module1.Test"

Don't forget to change the workbook path in the code

Follow the steps in the tutorial folder



VBS File


The VBS file format was developed by Microsoft Corporation as an executable file format. These VBS files are also known as Visual Basic script files, and are affixed with the .vbs file extension. These VBS files are classified as source code and program files for Windows PCs.

A .vbs file contains lines of codes in the Visual Basic programming language and may be associated with other programs. These VBS files are encoded in plain text format. It's advised to be careful when opening VBS files, especially when these .vbs files are sent as email attachments by unknown sources.

These VBS files can be opened as executable files in a Windows PC. Standard text editing applications like Notepad can also be used to view and edit the content of these .vbs files. A VBS file can also be opened and edited using Microsoft Visual Studio.

You can create simple text file and when saving add the extension .vbs to the file name

by Super Expert (1.9k points)
FYI - there's no need to create the Excel file with a macro, since you can display a MsgBox directly from a .vbs file using VBScript.
by Beginner (26 points)
edited by
Thank you both

Wellsr and yasser

, but can you explain what is .vbs file?
by Skilled (401 points)
You're welcome. I have updated the post

by Beginner (26 points)
Dear All,

Sometimes the need of the msgbox in the startup for reminders (such as payment or meeting ) in a list in an excel sheet.

Can I update the data (code) in the .vbs file on daily base according to that excel sheet so the msgbox became updated without opening an excel file once I open the windows.
by Skilled (401 points)
That's not clear for me. Can you give more details, please?

Welcome to wellsr Q&A
wellsr Q&A is the VBA and Python programming community that rewards you for learning how to code.

Earn free prizes for asking VBA and Python questions and for answering questions asked by others in our community.

What makes us different?
Our points system rewards you with a chance for free gifts based on the quality of your questions and/or answers. Users that ask great questions, may be given complimentary gift cards or training material.

Getting Started

So, why don't you join us? It really is a neat way to reward the most dedicated members in our VBA and Python community.

For more programming tips visit the VBA Tutorials Blog and the Python Tutorials Blog.