Go Back   Access World Forums > Apps and Windows > Visual Basic

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 12-24-2017, 10:22 AM   #1
AVILLAGE
Newly Registered User
 
Join Date: Dec 2017
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
AVILLAGE is on a distinguished road
Webbrowser control source from VBA string and .HMTL file

Iím trying to set a Access form web browser (wbmap2) control source by creating a text string and then using the property setting wbmap2.ControlSource = textstring. This is the web browser that comes with Access 2010, NOT the ActiVex variety. I want to use Bing Map scriptcontrol V8, so I have loaded some HTML code from their SDK site.
I first built a long text string in VBA and tried .navigate, but this only works with activex variety of the control.... and with even with the Activex the string didn't work, even though it seemed to be the code specified by Bing Maps (SDK V8, load map asyncHTML)

So I then saved the code in a file, OpenMap.html.
When I open that file in IE 11 (or Chrome) it opens as it should, but when I use this file asthe web browser control source , it throws a script error.

I first initialize the browser when the form opens, then try and set the control source when the document completes. At that point there is a script error that points to a problem with code in the saved file- it seems to be in the URL bit.
This may an issue for HMTL developers, but I canít see why a file that works OK when loaded directly to a browser then doesnít work as a control source. Is it a security setting in Access / the webbrowser control?
VBA code:
Code:
Private Sub Form_Load()

wbmap2.ControlSource = " about:blank"
Me.Refresh
End Sub


Private Sub wbmap2_DocumentComplete(ByVal pDisp As Object, URL As Variant)

'wbmap2.ControlSource = "=("" [bing maps normal web address]"")"   'works OK
wbmap2.ControlSource = "=""[file location on my computer]"""
Me.Refresh
End Sub
Can't seem to post the HTML code as I'm a newbie to this game...

Ideas / experience gratefully received...web and web browser controls are new territory for me!

AVILLAGE is offline   Reply With Quote
Old 12-24-2017, 11:50 AM   #2
isladogs
Part time moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 7,350
Thanks: 92
Thanked 1,811 Times in 1,686 Posts
isladogs is a glorious beacon of light isladogs is a glorious beacon of light isladogs is a glorious beacon of light isladogs is a glorious beacon of light isladogs is a glorious beacon of light
Re: Webbrowser control source from VBA string and .HMTL file

As I suggested in my response to your first post, I think you will find Google maps API easier to work with

I suggest you look at this sample database which links postcodes to Google maps
https://www.access-programmers.co.uk...d.php?t=295378

Even if you want to stick with Bing, the code may be worth looking at

The full version of this app will be available next month here:
http://www.mendipdatasystems.co.uk/u...der/4594138311
As well as postcodes, that links maps to geo-coordinates or full addresses

Quote:
So I then saved the code in a file, OpenMap.html.
When I open that file in IE 11 (or Chrome) it opens as it should, but when I use this file as the web browser control source , it throws a script error.
There is an issue linking some online maps to web browser controls in recent versions of Access / Windows. I don't know whether it also affects Bing maps.
This issue occurs because the web browser still expects to use Internet Explorer 7 after all these years.
The fix is a registry hack which I described here:
https://www.access-programmers.co.uk...d.php?t=297244
__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Colin
Previously known as ridders : Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
isladogs is offline   Reply With Quote
Old 12-24-2017, 12:03 PM   #3
jleach
Newly Registered User
 
jleach's Avatar
 
Join Date: Jan 2012
Location: New York, NY
Posts: 307
Thanks: 16
Thanked 69 Times in 69 Posts
jleach will become famous soon enough
Re: Webbrowser control source from VBA string and .HMTL file

It might be part of IE's ridiculous MOTW "feature", which prevents certain actions if the file is served locally (why anyone thought this was a good idea, I'll never know):

https://msdn.microsoft.com/en-ca/lib...or=-2147217396

After the DOCTYPE line, put the following:

Code:
<!-- saved from url=(0022)http://www.dymeng.com/ -->
... and see if it works any better.

Screenshot 2017-12-24 15.03.28.png

__________________
- Jack D. Leach

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Microsoft MVP 2012-2016
jleach is offline   Reply With Quote
Old 12-29-2017, 03:02 AM   #4
AVILLAGE
Newly Registered User
 
Join Date: Dec 2017
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
AVILLAGE is on a distinguished road
Re: Webbrowser control source from VBA string and .HMTL file

Thanks for the help ridders & Jleach- much appreciated! the immediate problem was related to the default IE browser version (7) when I have IE11... registry key change sorted that. I also added the MOTW line just in case.
Well now I can load a file saved on my machine into the standard webbrowser using ControlSource value set to the file name.
So the next trick was to write the file from my VBA programme when the form loads (eventually I want to give it the co-ordinates to centre the map). I used the standard .write to file method ... which didn't work because it left the quote marks in the file, so then I used .print. Made the file OK, which looks identical in every respect to the Bing Maps syntax I downloaded. So here's the rub... the downloaded syntax works fine in IE and as a ControlSource for my webbrowser:
The created syntax in the new file works fine in IE11, but NOT as a control source for my web browser. It just leaves the control blank.
So I have tried using the Activex version of the web browser and 'navigate2' the written file- no luck (same thing download version OK, .print version nothing). I've tried saving the syntax as a variable and navigating2 (activex) but this throws syntax error from the HTML code (which I suspect is not an error since that code works OK in a web browser).

So today's conundrum is 'why doesn't the web browser control like a file created in VBA as a ControlSource when the same file work in a web browser? I could post the VBA code, but I'm not sure that's the problem.. seems to be something to do with reading files created in VBA.

Looking around, this issue of creating dynamic HTML code VB /VBA and getting it to work in a web browser controls (standard or Activex) seems to have been an on-going issue for years (some of the threads I'm looking at are over a decade old). Just wondering if MicroSoft has a current solution that works for Access 2010 and Windows 7 (32 bit).
Many thanks!

AVILLAGE is offline   Reply With Quote
Reply

Tags
.hmtl file , controlsource , vba access 2010 , web browser control

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Webbrowser control inside a Tab control display problem edddiiie Forms 3 06-19-2014 05:15 PM
Webbrowser control act as file explorer elguapo Modules & VBA 0 03-01-2013 09:56 AM
View doc file in webbrowser control JPaulo Forms 4 04-11-2012 03:05 AM
Print and File Save methods with Acess 2010 WebBrowser or ActiveX WebBrowser control blueshorn General 0 03-06-2012 11:28 AM
WebBrowser Control Tallica Forms 13 02-17-2011 08:34 AM




All times are GMT -8. The time now is 09:51 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World