Solved

ust html in ms/access WebBrowswer

Posted on 2016-10-11
11
69 Views
Last Modified: 2016-11-16
In order to have control  of the parameters that I need to send to google maps (to be shown embedded in a control on a web form, according to Google Maps, I need to be able to "store" either a javascript or a html script in it, for which I can find no manner to do.

By googling a bit, I found the following suggestion on stack exchange:

Well, I decided to use the ActiveX WebBrowser control instead of the native WebBrowser for Access 2010/2013 since the former accepts the html string and formats the document correctly by using the write property of the document.

QUOTE
With Me.WebBrowser6.Object
    .Navigate2 "about:blank"
    .Document.write rst.Fields(2)
    .Refresh
End With

UNQUOTE

but nothing happens

can anyone help me?
0
Comment
Question by:jirdeaid
  • 6
  • 4
11 Comments
 
LVL 33

Expert Comment

by:ste5an
ID: 41840407
Well, I decided to use the ActiveX WebBrowser control instead of the native WebBrowser for Access 2010/2013 since the former accepts the html string and formats the document correctly by using the write property of the document.

D'oh? WebBrowser can do this also.

But .Refresh is not necessary nor does it something useful here.
0
 

Author Comment

by:jirdeaid
ID: 41840502
The question is: How does it?
0
 
LVL 33

Accepted Solution

by:
ste5an earned 500 total points
ID: 41840526
Misunderstood your post. Use ActiveX instead:

With Me.WebBrowser6.Object
     .Navigate "about:blank"
     .Document.write "<h1>Test</h1>
 End With

Open in new window

Q28975670.accdb
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

Author Comment

by:jirdeaid
ID: 41840631
Thanks a lot.

A thanks for the example.

So, it I replace "<h1>Test<h1> and using the proper CR chars, wuth

<!DOCTYPE html>
<html>
    <head>
        <title>createPushpinFromCanvasHTML</title>
        <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
    </head>
    <body>
        <div id='printoutPanel'></div>
       
        <div id='myMap' style='width: 100vw; height: 100vh;'></div>
        <script type='text/javascript'>
            function loadMapScenario() {
                var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
credentials:                     'Your Bing Maps Key'
                });
                var pushpin = new Microsoft.Maps.Pushpin(map.getCenter(), {
                    icon: createRedArrow(45),
                    anchor: new Microsoft.Maps.Point(12, 12)
                });
                map.entities.push(pushpin);
                function createRedArrow(heading) {
                    var c = document.createElement('canvas');
                    c.width = 24;
                    c.height = 24;
                    var ctx = c.getContext('2d');
                    // Offset the canvas such that we will rotate around the center of our arrow
                    ctx.translate(c.width * 0.5, c.height * 0.5);
                    // Rotate the canvas by the desired heading
                    ctx.rotate(heading * Math.PI / 180);
                    //Return the canvas offset back to it's original position
                    ctx.translate(-c.width * 0.5, -c.height * 0.5);
                    ctx.fillStyle = '#f00';
                    // Draw a path in the shape of an arrow.
                    ctx.beginPath();
                    ctx.moveTo(12, 0);
                    ctx.lineTo(5, 20);
                    ctx.lineTo(12, 15);
                    ctx.lineTo(19, 20);
                    ctx.lineTo(12, 0);
                    ctx.closePath();
                    ctx.fill();
                    ctx.stroke();
                    // Generate the base64 image URL from the canvas.
                    return c.toDataURL();
                }
               
            }
        </script>
        <script type='text/javascript' src='http://www.bing.com/api/maps/mapcontrol?branch=release&callback=loadMapScenario' async defer></script>
    </body>
</html>

will it work?

by
0
 
LVL 33

Expert Comment

by:ste5an
ID: 41840713
Basically, yes. But the question is: Why not storing this as local HTML file and distributing it with your database file?
0
 

Author Comment

by:jirdeaid
ID: 41840751
You are right!

My problem is "theoretically" quite simple:

I want to show some points for which, in my database, I do have GPS coordinates some pushpins, an text that depend on the type of point. Like this:

PointRef     Lat    Lon   Type        Text
r1                 La1   Lo1   Ty1          Txt1
r2                 La2   Lo1   Ty2          Txt2
r3                 La2   Lo1   Ty2          Txt2


So I want to plot in a map, Google Maps or Bing those 3 points. The map is to be shown inside the WebBrowser.

the code I have sent you is exactly the code that microsoft uses as example to use Bing:

http://www.bing.com/api/maps/sdk/mapcontrol/isdk#createPushpinFromCanvas+JS

so it easy for me just to alter it to my specific case, but I can also use Google Maps.

what would be your suggestion?
0
 
LVL 33

Expert Comment

by:ste5an
ID: 41840793
Pretty simple: Inject the data.

Create JavaScript function to take the data as parameter and call it from Access.

Apparently I'm writing an article about it. So when you can wait some days..
0
 

Author Comment

by:jirdeaid
ID: 41840831
Well... I don't know anything about javascript, so it is, right now, beyond my capabilities. However, if your article, is able to provide easy examples, I will follow it immediately! - how can I know about it? (my email?:joao.serras.pereora@ware.pt)

anyway, I am sending you the database with the "new" code that I have sent you, but it does not work: a totally white page is what is shown... I am sure that the error is mine, and if I can't get to a solution I'll ask a new question...

I am closing this page
Q28975670.accdb
0
 

Author Comment

by:jirdeaid
ID: 41840835
THANKS!
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 41885355
This is because IE is the browser called and it has to run a local script in low security mode. It can be a file you open, or it can be dynamic using strMap:

    WebBrowser.Navigate "about:Blank"
    WebBrowser.Document.Write strMap

but still, the script security will kick in and block.

You may have to run the script off a file from a (local) web server to get passed the strict security.

/gustav
0
 

Author Closing Comment

by:jirdeaid
ID: 41890948
thanks for the help!
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question