Macro to OK Windows Security

edwardj3

New Member
Joined
Jan 16, 2018
Messages
41
Office Version
  1. 365
Platform
  1. Windows
Morning all,

Got a macro which imports tables from internal web pages. I currently have to 'OK' when the Windows Security alert appears. The pop-up states that the server xxxxx is asking for your username and password. These details are already populated and stored from previous entry so I just click OK and the remaining code runs to completion. Is it possible to automatically select OK when the pop-up appears.

I've found a reference to SendKeys and there may be a need to wait but this does not resolve my issue. Code extract below

ActiveWorkbook.Worksheets.Add
ActiveSheet.Name = fmtToday_a




With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://" & fmtToday, _
Destination:=Range("$A$1"))
.Name = fmtToday
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False 'this is where the code is highlighted when I do not press OK and debug

End With


Application.Wait (Now() + TimeValue("00:00:05"))
SendKeys ("{ENTER}")

Any advice you can provide would be really appreciated as I'm looking to auto-run the macro through the night so it is available when we get into work to issue. Using Windows 7 and Excel 2007.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Forum statistics

Threads
1,223,905
Messages
6,175,297
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top