removing the scroll bars and borders from the web browser object - vba

I have a powerpoint that is using a web browser object. The trouble is that the scrollbars on the web browser object are always there, regardless of whether or not they are needed. Is there some way to remove the scroll bars?
I have tried adding:
WebBrowser.Document.body.Scroll = "no"
but that makes the object stop working all together.
Also, the object has a thin light colored (i think it is white but it is hard to tell) border around it. Since most of my presentation is black this does not blend well though i have set the background color of the html displayed to be black. Is there a way to get rid of the border as well?
if they cannot be done with vba can they be done at all?

My understanding is no, this is not possible. I dislike the scroll bar, but it's a part of IE and I don't see any way to remove it without completely disabling functionality as you have already seen.

JimmyPena,
I did it. After some tests I discovered that if I set the image to webbrowser and try to set other Document.Body properties in the same "f5" execution it didn't work.
If you try to use "f8", it works, ironically.
I think it is because that webbrowser component cannot set some properties after loading an object.
Sooooo, i tried to make an HTML file in which my object (in my case, an gif image) was set and all properties was set as well, including scroll removal, margin removal and border removal.
You can see my codes below.
HTML (test.html):
<html>
<head>
</head>
<body style="overflow: hidden; margin: 0; border: 0;">
<img src="Assets/loading-small.gif" />
</body>
</html>
VBA:
Sub abaSV_showLoadingIcon()
AbaSV.WebBrowser1.Visible = True
AbaSV.WebBrowser1.Navigate ThisWorkbook.path & "\test.html"
End Sub
I think that should help you, JimmyPena and uncertaintea.
SeeYa!

Your idea works just fine, except for the VBA part.
So what I did is to creat a html file as you did, assigning the properties and calling the gif image.
Then in VBA i used the following code (in the sheet where the webborser can be found):
Private Sub worksheet_activate()
WebBrowser1.Navigate "insert html file path.html"
End Sub

I solved this by applying in the html file this code under the <head> tag:
<style type="text/css">
html {
overflow:hidden;
}
</style>

Use Document.Body.Scroll = "No" to disable scroll bar in Webbrowser
Option Explicit
Private Sub
UserForm_Activate()
WebBrowser1.Navigate "C:-Download-P.gif"
End Sub
Private Sub
WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
With WebBrowser1
. Width = 80
. Height = 80
. Document.Body.Scroll = "No"
End With
End Sub

Related

How can I wrap the text in a ListBox?

I am populating a ListBox with the current function:
Public Function fillListBox5(theList As List(Of FARG_Data))
For Each item In theList
ListBox5.Items.Add(item.getFargFunction)
Next
End Function
This works well, but some of the item's FargFunctions are decently long causing portions of the string to be cut off at the end of the ListBox. Is there anyway I can make the text wrap so that none of it is cut off?
Set the ListBox.HorizontalScrollbar property to True. This can either be done within the designer or programmatically:
ListBox5.HorizontalScrollbar = True
This will give the user the ability to scroll and view all the text:
Or you can set the css style overflow: auto;
select {
overflow: auto;
}

VBA & HTML Objects - click invisible dropdown

I'm trying to trigger the event main.filaPopupV3_1.select('alta'); via VBA in IE8
The dropdown main.filaPopupV3_1 is invisible until another button is clicked. I can get the dropdown to become visible but i can't access any of the options in it.
'alta'
Is one of the options i want to click.
Thats my code which isn't working.
'IE References at start are
Set myIE = New InternetExplorerMedium
Set Document = myIE.Document
I skip the navigation etc.
Document.getElementById("BViewElementCSSIcon5").FireEvent ("onmouseover")
Document.getElementById("BViewElementCSSIcon5").FireEvent ("onclick")
Document.getElementById("main_filaPopupV3_1_main_filaPopupV3_1_root").FireEvent ("onmouseover")
Document.getElementById ("main.filaPopupV3_1._cancelHide=1;")
Document.getElementById ("main.filaPopupV3_1.hideMenu('alta');event.cancelBubble=true;")
Document.getElementById("main.filaPopupV3_1('alta')").FireEvent ("onmouseover")
Document.getElementById ("main.filaPopupV3_1.select('alta');")
Document.getElementById("alta").Click
I know that some lines are unnecassary. Thats just me trying so far
HTML source code
Here's the answer but if someone could explain why this is working, i'd be very happy. Thanks
myIE.Navigate ("javascript:main.filaPopupV3_1.select('alta');")

Visual Basic PictureBox Panel Flicker

I am making a simple game that (for the main part) consists of a Panel with a grid of 32 PictureBoxes inside, each with a BackgroundImage. You click on a "tile" and it flips revealing a picture. My problem is that when the Form Loads, I can see it drawing. I see the Panel .. then empty PictureBoxes, then finally it fills in the PictureBoxes with the BackgroundImages.
I've turned DoubleBuffer to True for the Form, and I've also added the following:
Private Sub UseDoubleBuffer()
Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True)
Me.UpdateStyles()
End Sub
Which I call when the Form Loads. I'm not sure what else I can do? I want it to just 'pop' onto the screen. Why isn't the DoubleBuffer working? Do I need to code the panel manually? I was trying to avoid that as it's obviously easier to just drag and drop into the Form, but if I need to, I will.
I can't post screenshots apparently, as my rep isn't high enough yet, but believe me, it looks hideous, and I do want to make this as sleek as I possible can. Any ideas?
Try creating flicker free custom panel controls:
Here are the steps to use this control:
1. Add new class "NonFlickerPanel" to your C# application.
2. Replace autogenerated class code with C# code shown below.
3. Use NonFlickerPanel object instead of Panel object in your application.
public partial class NonFlickerPanel : Panel
{
public NonFlickerPanel() : base()
{
this.SetStyle(ControlStyles.AllPaintingInWmPaint,
ControlStyles.UserPaint
ControlStyles.OptimizedDoubleBuffer,
true);
}
}
Try making the picture boxes invisible (.visible = false) until they're all loaded, then set visible to true for all of them.

Hide page contents until filters are applied in WebBrowser Control

I'm modifying web contents displayed in a webbrowser control and looking for a way not to display them until all the changes are applied.
I'm currently using the DocumentComplete event and while filtering some pages, their contents are just visible. So I'd like to hide them until everything becomes okay to be shown.
simple.html
<html>
<head>
<style type="text/css">
div {
font-weight: bold;
}
</style>
</head>
<body><div>foo</div> bar</body>
</html>
demo script
new WBControl("file:///" A_ScriptDir "/simple.html")
class WBControl {
DocumentComplete(oParams*) {
doc := oParams[3].document
sleep 200 ; simulate a delay caused by a heavy task
doc.styleSheets[0].rules[0].style.fontweight := "normal"
}
__New(strURL="") {
static WB
Gui, New, Resize MaximizeBox
Gui, Add, ActiveX, vWB w780 h580, Shell.Explorer
Gui, show, w800 h600
ComObjConnect(WB, this)
WB.Navigate(strURL)
}
}
Is there a way to do it?
Try:
document.body.style.visibility := "hidden"
To restore visibility, set it to an empty string.
document.body.style.visibility := ""
You could also create a simple loading display to show instead; if you want to be fancy.

Modify HTML in a Internet Explorer window using external.menuArguments

I've got a VB.NET class that is invoked with a context menu extension in Internet Explorer.
The code has access to the object model of the page, and reading data is not a problem. This is the code of a test function...it changes the status bar text (OK), prints the page HTML (OK), changes the HTML by adding a text and prints again the page HTML (OK, in the second pop-up my added text is in the HTML)
But the Internet Explorer window doesn't show it. Where am I doing wrong?
Public Sub CallingTest(ByRef Source As Object)
Dim D As mshtml.HTMLDocument = Source.document
Source.status = "Working..."
Dim H As String = D.documentElement.innerHTML()
MsgBox(H)
D.documentElement.insertAdjacentText("beforeEnd", "ThisIsATest")
H = D.documentElement.outerHTML()
MsgBox(H)
Source.status = ""
End Sub
The function is called like this from JavaScript:
<script>
var EB = new ActiveXObject("MyObject.MyClass");
EB.CallingTest(external.menuArguments);
</script>
To the best of my understanding, in order to use insertAdjacentText or any of the other editing methods, the document object should be in the design mode.
In design mode you can edit the document freely, and so can the user.
Check this site for more details
I do not think that Alex is right, something else is the matter.
When I tried to do something like that, insertBefore would not work for me, but appendChild worked just fine, so adding an element is possible.
I worked in Javascript, but I don't expect that makes a difference.