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 6780729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:32:25+00:00 2026-05-26T16:32:25+00:00

I have some VBA code that opens a webpage, then calls a javascript function

  • 0

I have some VBA code that opens a webpage, then calls a javascript function that deletes a file off of the page. When this function is called, it calls a window.confirm in the HTML to make sure that the user really wants to delete the file. The options are yes and cancel. My question- Is there any way to automatically make my VBA code answer yes? As it is, I can automate everything but the “yes” click, which means I still have to sit there and click yes for every file that it wants to delete; it’d be nice to run the code and be able to walk away.
edit: if it helps, here is the code I’m using to execute the javascipt. Also, the javascript function code

My code:

Dim CurrentWindow As HTMLWindowProxy: Set CurrentWindow = IE.Document.parentWindow

m = 2

Do Until date_var < "2011-7-1"

        Cells(1, 11).Value = Range("j1") - m
        date_var = Cells(1, 11).Value
        date_var = Format(date_var, "yyyy-m-d")

        Call CurrentWindow.execScript("Delete('filepath_here_" & date_var & ".csv?DELETE')")

Javascript Function:

<SCRIPT LANGUAGE="JavaScript">
function Delete(What)
{
   if (window.confirm("Do you really want to delete this file"))
   {
      location.href = What;
   }
}
</SCRIPT>
  • 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-26T16:32:26+00:00Added an answer on May 26, 2026 at 4:32 pm

    I don’t know VBA, but try the following script:

    Call CurrentWindow.execScript("location.href='filepath_here_" & date_var & ".csv?DELETE';")
    

    That should do the trick. It’s better than calling the delete function directly. No function call overhead, no side effects, and no confirm box. Replace the last line of your code with this one and check.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some VBA code that needs to talk to a running c# application.
I have written some SAS code that calls R via the x command (I
I have some VBA code that looks like this and the aim is to
i have some vba code that i need to convert to c# Select Case
I currently have some VBA code that runs through and modifies all my calendar
I have an Excel workbook, which using VBA code that opens another workbook, copies
I have an Excel file that has a bunch of VBA and macro code
I have some VBA code that saves the spreadsheet under a given filename. Whenever
Hidden worksheets/workbooks have some limitations to what can be done in VBA code, like
I have created a report in MS Access report and write some VBA code

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.