admin管理员组文章数量:1415644
I am trying to execute the mand toggletable or showall function on a javascript page that has the tables information hidden until you click on the + button next to it. I would like to just make these automaticly expanded for printing purposes. Here is what I have so far.
Function PrintWebPage()
Const OLECMDID_PRINT = 6
Const OLECMDEXECOPT_PROMPTUSER = 1
Const OLECMDEXECOPT_DONTPROMPTUSER = 2
Dim ie As Object
Dim strWebPage As String, stblAutoNumber(99999) As String, stblBadgeNumber(999999) As String, stblShopNumber(99999) As String
DoCmd.SetWarnings False
' Connect to DB
Set db = CurrentDb()
' Select Statement for scrolling through everyone
sqlString = "SELECT tblPersonal.AutoNumber, tblPersonal.[Badge Number], tblPersonal.Shop , tblPersonal.[Last Name] FROM tblPersonal WHERE tblPersonal.[Shop] = " & """" & ShopUserATMS & """" & ";"
' Sets mRecordset to query the database
Set mRecordset = db.OpenRecordset(sqlString)
' Goes to first record of the generated list
mRecordset.MoveFirst
Do While Not mRecordset.EOF
' Scroll through personal List
stblAutoNumber(i) = mRecordset("AutoNumber")
CheckBadgeNull = mRecordset("Badge Number")
If IsNull(CheckBadgeNull) = True Then
GoTo NoRec:
End If
stblBadgeNumber(i) = mRecordset("Badge Number")
stblShopNumber(i) = mRecordset("Shop")
strWebPage = ".cfm?BADGE=" & stblBadgeNumber(i)
DoEvents: DoEvents: DoEvents
Set ie = CreateObject("internetexplorer.application")
ie.Navigate strWebPage
Do Until ie.Busy = False
sSleep (1)
Loop
Call ie.Document.parentWindow.execScript("toggletable(Quals)", "JavaScript")
'ie.getelementsbyid("Showall") = True
'stblShopNumber(99) = ie.Document.execmand("toggletable", False, Null)
ie.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER
sSleep (2)
NoRec:
Loop
ie.Quit
Set ie = Nothing
End Function
It gives me access denied when I use the following mand: Call ie.Document.parentWindow.execScript("toggletable(Quals)", "JavaScript")
Any help is appreciated. Beating my head on this one for over 8 hours...
I am trying to execute the mand toggletable or showall function on a javascript page that has the tables information hidden until you click on the + button next to it. I would like to just make these automaticly expanded for printing purposes. Here is what I have so far.
Function PrintWebPage()
Const OLECMDID_PRINT = 6
Const OLECMDEXECOPT_PROMPTUSER = 1
Const OLECMDEXECOPT_DONTPROMPTUSER = 2
Dim ie As Object
Dim strWebPage As String, stblAutoNumber(99999) As String, stblBadgeNumber(999999) As String, stblShopNumber(99999) As String
DoCmd.SetWarnings False
' Connect to DB
Set db = CurrentDb()
' Select Statement for scrolling through everyone
sqlString = "SELECT tblPersonal.AutoNumber, tblPersonal.[Badge Number], tblPersonal.Shop , tblPersonal.[Last Name] FROM tblPersonal WHERE tblPersonal.[Shop] = " & """" & ShopUserATMS & """" & ";"
' Sets mRecordset to query the database
Set mRecordset = db.OpenRecordset(sqlString)
' Goes to first record of the generated list
mRecordset.MoveFirst
Do While Not mRecordset.EOF
' Scroll through personal List
stblAutoNumber(i) = mRecordset("AutoNumber")
CheckBadgeNull = mRecordset("Badge Number")
If IsNull(CheckBadgeNull) = True Then
GoTo NoRec:
End If
stblBadgeNumber(i) = mRecordset("Badge Number")
stblShopNumber(i) = mRecordset("Shop")
strWebPage = "https://was3.nnsy.navy.mil/atms/ponents/supervisor/atms_supv_detail.cfm?BADGE=" & stblBadgeNumber(i)
DoEvents: DoEvents: DoEvents
Set ie = CreateObject("internetexplorer.application")
ie.Navigate strWebPage
Do Until ie.Busy = False
sSleep (1)
Loop
Call ie.Document.parentWindow.execScript("toggletable(Quals)", "JavaScript")
'ie.getelementsbyid("Showall") = True
'stblShopNumber(99) = ie.Document.execmand("toggletable", False, Null)
ie.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER
sSleep (2)
NoRec:
Loop
ie.Quit
Set ie = Nothing
End Function
It gives me access denied when I use the following mand: Call ie.Document.parentWindow.execScript("toggletable(Quals)", "JavaScript")
Any help is appreciated. Beating my head on this one for over 8 hours...
Share Improve this question edited Aug 29, 2015 at 7:14 marc_s 757k184 gold badges1.4k silver badges1.5k bronze badges asked Jan 14, 2011 at 22:13 ChazChaz 311 gold badge1 silver badge3 bronze badges 1- did you end up solving the problem? (and I'm not talking about DontFretBrett's alternative method, since that is not an answer to your question). If you did figure out why Access Is Denied is thrown, please do share since I am having the same problem. – Erx_VB.NExT.Coder Commented Dec 17, 2012 at 10:31
2 Answers
Reset to default 1You need to enable "Allow active content to run in files on My Computer" option from Internet Options-->Advanced-->Security. If you want to change this IE setting programmatically, below is the vbscript code for it:
Const HKEY_CURRENT_USER = &H80000001
strComputer = "."
dwValue = 0
Set objReg = GetObject("winmgmts:" & "{impersonationLevel=impersonate}\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_LOCALMACHINE_LOCKDOWN"
objReg.SetDWORDValue HKEY_CURRENT_USER, strKeyPath,"iexplore.exe",dwValue
set dwValue to 0 to enable, and 1 to disable the IE setting.
Dim IE As New InternetExplorer
IE.Visible = True
IE.navigate "http://www.google."
Do: DoEvents: Loop Until IE.readyState = READYSTATE_COMPLETE
IE.navigate "javascript:alert('hi');"
本文标签: Trying to use VBA to execute a javascript command on a webbrowser controlStack Overflow
版权声明:本文标题:Trying to use VBA to execute a javascript command on a webbrowser control - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745240839a2649319.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论