Nhấn OK trên cửa sổ cảnh báo bật lên qua VBA (Press OK on pop-up alert window via VBA)


問題描述

Nhấn OK trên cửa sổ cảnh báo bật lên qua VBA (Press OK on pop‑up alert window via VBA)

Having an issue, I have written a Macro ,that refreshes every 2 min, to upload data from a webpage and the last step of my Macro is using "Text to column" function so that it will be splitted into columns nicely.

The problem appears here everytime it gets to executes this "Text to column" it asks if I want to overwrite the columns(and I DO), but I need to press manually OK.

Is there any way to make VBA press this OK button in the alert?

Thank you very much!


參考解法

方法 1:

Just add Application.DisplayAlerts = False prior to the call, and set it back to True after.

http://msdn.microsoft.com/en‑us/library/office/aa175241%28v=office.11%29.aspx


Update: I just ran a test and it does not prompt me by default. Can you post the code you're using? I simply did:

Public Sub Test()
    Dim r As Range
    Set r = ActiveWorkbook.Sheets(1).Columns("A:A")
    r.TextToColumns Destination:=Range("B1")
End Sub

This link says the DisplayAlerts solution has worked in for others.

方法 2:

You can add a DoCmd.SendKeys BEFORE the instruction that generates the  dialog.

方法 3:

You should use mouse click function Before it maximize window so x,y cordinates of ok buttons remain same Use windows lib 32

(by maximladusnunzabariDevlopbhupendra singh)

參考文件

  1. Press OK on pop‑up alert window via VBA (CC BY‑SA 3.0/4.0)

#Automation #excel #vba






相關問題

GNOME 應用程序可以自動化嗎?如何? (Can a GNOME application be automated? How?)

Nhấn OK trên cửa sổ cảnh báo bật lên qua VBA (Press OK on pop-up alert window via VBA)

如何使用硒驗證谷歌搜索結果是否包含特定文本? (How to verify whether google search results consist of a specific text using selenium?)

如何在 selenium xpath 中的多個 div 之間獲取子父 Web 元素組件? (how to get a sub parent web element component between many div in selenium xpath?)

在 BMC 補救措施 8.1 中安排每月事件報告 (schedule monthly incidents reports in BMC remedy 8.1)

將 MS Excel 鏈接到 MS Access 查詢 (Linking MS Excel to MS Access queries)

工作項是否可以(或需要)在 TFS 中對構建進行排隊? (Is it possible (or desirable) for a work item to queue a build in TFS?)

使用腳本自動將數據輸入到 OpenOffice Calc 電子表格 (Using a script to automate data entry to an OpenOffice Calc spreadsheet)

使用 DjVu 工具進行背景/前景分離? (Using the DjVu tools to for background / foreground seperation?)

C# FindElement(By...) 有兩個條件 (C# FindElement(By...) with two criteria)

如何使用 IDM 自動下載? (How can I automate downloads using IDM?)

通過Java程序運行時如何在shell腳本中提供輸入選擇? (How to provide input selection in shell script when running though Java program?)







留言討論