Gif File

mahmed1

Well-known Member
Joined
Mar 28, 2009
Messages
2,302
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi All,

I have done many researches but cant seem to find the right 1 to get it to work

I want to display a gif file in a certain location in my worksheet without having any scroll bars

I have tried to draw the web tool on my machine at both home and work but i get an error saying that i draw this object

Can you please help me get around this

Thank You
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
I don't think you can (well not easily anyway). Microsoft removed the ability to place the web browser control into worksheets due to security concerns. I believe that there is a registry key you can change to re-enable this, but it's not advisable and anyone wanting to see the gif would need to fiddle with the registry on their machine.

The alternative would be to not use a gif, or put it on a userform
 
Upvote 0
Thank you

The thing with a userform is that the userform has scroll bars and title

i want to be able to position it exactly in a certain location making it look like the gif image is not part of the userform so its like transparent

is this possible?
 
Upvote 0
No, not without faffing with the registry or copious amounts of windows apis
 
Upvote 0
Hi Kyle

Just wanted to get your views on this

Often when people want to do some kind of animation they use DoEvents in a loop and many use Windows API sleep function instead to get the same effect

my question is - is it better, slicker, quicker to use 1 over the other and which 1 would you use?
 
Upvote 0
If you use the webbrowser on a userform, you should be able to remove its scrollbars and make it transparent so it nicely blends with the userform background as you requested.

Take a look at this workbook demo.

Code in the Userform module :

Code:
Option Explicit

[URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=If"]#If[/URL]  VBA7 Then
    Private Declare PtrSafe Function TranslateColor Lib "oleaut32.dll" Alias "OleTranslateColor" (ByVal clr As OLE_COLOR, ByVal palet As Long, Col As Long) As Long
[URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=Else"]#Else[/URL] 
    Private Declare Function TranslateColor Lib "oleaut32.dll" Alias "OleTranslateColor" (ByVal clr As OLE_COLOR, ByVal palet As Long, Col As Long) As Long
[URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=End"]#End[/URL]  If

Private Sub UserForm_Initialize()
    WebBrowser1.Navigate ("http://www.cslab.ece.ntua.gr/~phib/images/doom/anim/spos00.gif")
    DoEvents
End Sub

Private Sub BlendGIFBackground_Click()
    Dim R As String, G As String, B As String
    Dim lRealcolor As Long

    With WebBrowser1
        .Document.body.setattribute "scroll", "no"
        .Document.body.Style.Border = "none"
        TranslateColor Me.BackColor, 0, lRealcolor
        FindRGB lRealcolor, R, G, B
        .Document.body.bgColor = "#" & Format((R), "00") & Format((G), "00") & Format((B), "00")
    End With

End Sub

Private Sub FindRGB(ByVal Col As Long, R, G, B)
    R = Hex(&HFF& And Col)
    G = Hex((&HFF00& And Col) \ 256)
    B = Hex((&HFF0000 And Col) \ 65536)
End Sub

EDIT:

If you are on a 32bit system you may need to change the TranslateColor API declaration as follows :

Code:
Private Declare Function TranslateColor Lib "olepro32.dll" Alias "OleTranslateColor" (ByVal clr As OLE_COLOR, ByVal palet As Long, col As Long) As Long
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,559
Messages
6,120,194
Members
448,951
Latest member
jennlynn

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top