Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ust html in ms/access WebBrowswer

Posted on 2016-10-11
11
Medium Priority
?
80 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:João serras-pereira
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
11 Comments
 
LVL 35

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:João serras-pereira
ID: 41840502
The question is: How does it?
0
 
LVL 35

Accepted Solution

by:
ste5an earned 2000 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:João serras-pereira
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 35

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:João serras-pereira
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 35

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:João serras-pereira
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:João serras-pereira
ID: 41840835
THANKS!
0
 
LVL 51

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:João serras-pereira
ID: 41890948
thanks for the help!
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

721 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