Excel Button and bat file

Anonymous
2020-02-10T02:47:01+00:00

I have the following batch file to copy a file from a source folder to potentially hundreds of destination folder:

@echo off

for /D %%a in ("C:\Users\USERname\OneDrive\Assignment\Section 3\Week 3 Section 3\*.*") do xcopy /y /d C:\Users\Username\Documents\starter.docx "%%a"

This works when I execute the batch file. 

I will like to share this with some of my non technical staff and I was wondering if I can create some kind of Menu system so that they will just click a button to execute this?

My initial thoughts was an excel button....what are my options and is this possible?

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2020-02-10T04:03:33+00:00

    Hi CanadianSai

    You can create a button control in Excel and place this scripts, see the picture.

    Private Sub CommandButton1_Click()

    Dim folderPath As String

    Dim shellCommand As String

    folderPath = Application.ActiveWorkbook.Path

    shellCommand = "c:\test\test.bat"

    Call Shell(shellCommand, vbNormalFocus)

    End Sub

    0 comments No comments