Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3983102
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:36:26+00:00 2026-05-20T05:36:26+00:00

As part of an Excel based scheduler that I have created, I am using

  • 0

As part of an Excel based scheduler that I have created, I am using the ‘Application.Ontime’ function in the following manner to execute macros at specified times

Sub Load
    //snipped for brevity

    Dim startName As String
    startName = "'StartSub""" & filePath & """, """ & fileName & """, """ & macroName & """'"

    Application.OnTime y, startName

End Sub

Sub StartSub(filePath As String, fileName As String, macroName As String)
    Dim wb As String
    wb = "'" & filePath & "'!" & macroName
    Application.Run wb
    Application.Workbooks(fileName).Close Savechanges:=True
End Sub

Testing and simple POC seems to have worked really well. The issue I am facing is that one of the spreadsheets is password protected. The problem is that password entry dialogue prevents the macro from executing which I guess is expected. There is no need for write access to the password protected workbook since the output and results are exported to several reports.

My question is how to overcome this and run macros from a password protected workbook using Application.Run?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T05:36:27+00:00Added an answer on May 20, 2026 at 5:36 am

    Since the workbook is password protected, a password always is supplied when openign the file. In order to overcome this, I needed to store the passwords in my workbook. So the issue actually boiled down to opening a file with the correct password.

    Sub StartSub(filePath As String, fileName As String, macroName As String)
        Dim wb As String
        wb = "'" & filePath & "'!" & macroName
        Dim scheduledWb As Workbook
    
        Dim pwd As String
        Dim saveChange As Boolean
        pwd = GetPassword(fileName) ' method that extracts correct password from somewhere
        If Len(pwd) > 0 Then
            Set scheduledWb = Workbooks.Open(fileName:=filePath, ReadOnly:=True, Password:=pwd)
            saveChange = False
        Else
            Set scheduledWb = Workbooks.Open(fileName:=filePath)
            saveChange = True
        End If
    
        Application.Run "'" & fileName & "'!" & macroName
        Application.Workbooks(fileName).Close Savechanges:=saveChange
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a repeatable business process that I execute every week as part of
Part of the GUI I'm building using tkinter has a pop-up window that says
Part of my web application is a background script that polls from a beanstalkd
I want to implement a VBA function to number Excel rows based upon the
We have a web-based product that is used for project management and planning. Each
I have a C# 3.0 WinForms application which is occasionally required to control Excel
I have a table called excel that has 3 columns, name , id ,
I'm generating an excel file using Apache POI 3.8 , and have the need
I have an excel sheet that is loaded with a dynamic result set of
I try to generate some Excel sheets in Java application using JExcelAPI (v. 2.6.3)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.