My default web browser is Google Chrome Version 39.0.2171.95 m. The following web address does not work properly in Chrome but does so in IE: "https://secure.crbonline.gov.uk/enquiry/multipleEnquirySearch.do". I have written the follwing code to try to open the link in IE but what it does is open IE and then open the hyperlink in Chrome. How can I get it to simply open in IE and not run Chrome in this instance?
Dim stAppName As String
stAppName = "C:\Program Files (x86)\Internet Explorer\iexplore.exe"
Call Shell(stAppName, 1)
FollowHyperlink "https://secure.crbonline.gov.uk/enquiry/multipleEnquirySearch.do"
Try including the URL along with stAppName.
Dim strApp As String
Dim strURL As String
strApp = "C:\Program Files (x86)\Internet Explorer\iexplore.exe"
strURL = "https://secure.crbonline.gov.uk/enquiry/multipleEnquirySearch.do"
Call Shell(strApp & " " & strURL, 1)
Related
I am trying to write a vb-script to do the following
Launch Chrome
Navigate to a specified website
Loop and keep refreshing that specific tab
I am able to get #1 and #2 to work, using the following code. The refresh works as well. The only issue is that the refresh happens to the windows which are active. The AppActivate part - which is supposed to shift focus to a given window is not working. Code here.
Dim iURL
Dim objShell
iURL = "SampleURL"
set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "chrome.exe", iURL, "", "", 1
Do While True
Set WSHShell = CreateObject("WScript.Shell")
WSHShell.AppActivate "Remote Access Asia - Google Chrome"
WSHShell.SendKeys "{F5}"
WScript.Sleep 30000 ' 30 seconds
Loop
The window title I am using was determined by using the tasklist command (tasklist /v /FO:CSV). I have tried using various versions (substrings) of the title shown. I have used chrome.exe as well, but nothing helps. The refresh is not limited to tabs of Chrome - it happens with other apps e.g. notepad as well.
Any thoughts would be much appreciated.
Your code worked fine for a Chrome window I already had open. The issue may be with ShellExecute. I had success using Run and ensuring the site opened in its own window using the --new-window parameter. It's also unnecessary to have the CreateObject inside the While loop. Try it like this:
Set oWSH = CreateObject("WScript.Shell")
URL = "SampleURL"
oWSH.Run "chrome.exe --new-window " & URL
Do While True
oWSH.AppActivate "Remote Access Asia - Google Chrome"
oWSH.SendKeys "{F5}"
WScript.Sleep 30000 '30 seconds
Loop
This is my code for opening Chrome browser on a variable page using vbscript:
Set browobj = CreateObject("Wscript.Shell")
siteA = "http://...../"
browobj.Run "chrome -url " & siteA
WScript.Sleep OneSecond*60
siteB = "http://..../Gest.do?operation=export&eser=123&ver=456"
browobj.Run "chrome -url " & siteB
Set browobj = Nothing
The first step opens the web page ( siteA ) for user authentication:
siteA = "http://...../"
browobj.Run "chrome -url " & siteA
The second step opens a link ( siteB ) where you pass variables for downloading an excel file :
WScript.Sleep OneSecond*60
siteB = "http://..../Gest.do?operation=export&eser=123&ver=456"
browobj.Run "chrome -url " & siteB
The second link ( siteB ) with the variables is opened in a new Chrome tab and the download is stopped.
Instead if the second link ( siteB ) opens in the same tab of the siteA the download is started. Tried manually.
I need reuse the same tab on is opening the siteA.
How to do opening the second link ( siteB ) opens in the same tab of the siteA ?
Please can you help me ?
Edit #01
browobj.Run start & siteB
Since chrome is available as a command:
chrome /new-tab somesite.com
However if chrome isnt available as a command but IS the default browser you can use:
start "" "https://somesite.com"
This should make it open in a new tab on the active window.
If you can't guarantee Chrome is the default browser. You can find the path to the chrome.exe and use something like:
"<Path of chrome here>" /new-tab "https://somesite.com"
I recently wrote an Excel VBA script to login and navigate an intranet site to download a CSV report. It contains some links and buttons that I need to click inside an iframe. It took some effort to figure out the iframe stuff, but it works. I still don't know how to click "Save" without the download file dialog box being the active window, but that's for another day.
I'm in the process of converting this script to VBS and have run into this error message:
Here are the relevant code snippets:
VBA Code (this works)
Set ie = New InternetExplorer
ie.Visible = True
...
Dim iframeDoc As MSHTML.HTMLDocument
Set iframeDoc = ie.document.frames("fmReports").document
' select the custom report
iframeDoc.getElementById("tvCustomReport").Click
Application.Wait (Now + TimeValue("00:00:03"))
' run the report
iframeDoc.getElementById("btnRunReport").Click
VBS Code (this presents the error dialog above)
Dim oIE
Set oIE = CreateObject("InternetExplorer.Application")
oIE.Visible = True
...
Dim iframeDoc
Set iframeDoc = oIE.document.getElementById("fmReports").ContentWindow.Document
' select the custom report
iframeDoc.getElementById("tvCustomReport").Click
WScript.Sleep 3000 'wait here just in case
' run the report
iframeDoc.getElementById("btnRunReport").Click
Questions/Thoughts
I've turned off just about every security feature I can find in IE.
Are these different domains? (XSS issue perhaps)
The main intranet site url is http://192.168.0.111/app2019 while the contents of the iframe url is http://192.168.0.111/app2018.
Line 49 (referenced in the screenshot) of my full script is the second line in the VBS snippet (Set iframeDoc =...)
Am I missing something obvious?
I have an access VBA script that exports to Excel. It opens the workbook, copies & formats the data and saves the workbook. It's worked for years. It worked on my old system with Office 13, and it works on my new system with Office 16. Now I'm trying to run this on another PC that was just set up - it has Office 13 installed, but may also have the Office 16 version installed that came with the new PC.
When I manually open Excel, Excel 2013 opens as it should. When my Access code runs and tries to open Excel, it seems to be going to the new version - and the code stops working, I think because the Office 16 account isn't set up and when Excel opens it goes to the Office 16 activation screen instead of opening the workbook.
The export macro code is
Public Function Export_data(Optional table As String, Optional opt As String = "")
Set wb_app = CreateObject("Excel.Application")
wb_app.Visible = False
wb_app.displayalerts = False
path = DLookUp("[report folder]", "folder")
If opt <> "" Then
FileName = path & "\" & opt & ".xlsm"
Set wb_obj = wb_app.workbooks.Open(FileName)
End If
The error occurs at "wb_app.workbooks.open" with the error "Unable to get the Open property of the Workbooks class." When I set .Visible to True and look at what Excel is doing, it's going to the activation screen for the Office 16 account.
How can I change the VBA code to direct it to the correct version of Excel?
You can specify the version by using the 2-digit office version at the end of the file, e.g.:
Set wb_app = CreateObject("Excel.Application.14") 'Office 2010
You can look in the registry under HKEY_CLASSES_ROOT to see what's available. Of course, you can query the registry using VBA if you want.
i need to take a snapshot with webcam when someone press a button in access form.
Is it possible?
i know how open a program from access but i'm stuck on how to trigger the event
the code
Private Sub Command1_Click()
Dim stAppName As String
stAppName = "C:\Program Files\myapp"
Call Shell(stAppName, 1)
End Sub
now let's say the snapshot trigger by f12 key in the app
how do i get the f12 key to click automatically
ok i got it
if any one want to know here is the method
1.by 2 macros "runapplication" & "sendkeys"
with "runapplication" just put the path of the app
with "sendkeys" just put the command SendKeys "{yorkey}"
by the way you need to press show all command in the the toolbar
or you can do it in vba code
You could try this if you are in windows 8/8.1
Dim cameraPath As String
cameraPath = "shell:AppsFolder\Microsoft.MoCamera_cw5n1h2txyewy!Microsoft.Camera"
Shell "explorer " & cameraPath