Excel - vba web browser

cds9892745745

New Member
Joined
Sep 2, 2009
Messages
9
I have a file which extracts employee entries when you put the employee code. Have created a form to show the progress % and estimated time for search.
In this form i have added a animation .gif file and it runs fine on my PC but not on any other PC as the .gif file is store on my desktop.
I want to store this .gif file on the workbook and any way i can set a path for the program to pick up the .gif file from the same excel workbook.
:confused:
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

bjurney

Active Member
Joined
Aug 24, 2009
Messages
320
Save your .gif in a shared drive and add the following code to your userform.

Code:
Private Sub UserForm_Initialize()
WebBrowser1.Navigate2 ("F:\Your Path\Goes Here\0060.gif")
End Sub


Best of luck
 

cds9892745745

New Member
Joined
Sep 2, 2009
Messages
9
Thanks bjurney
I Tried this - it works fine. However i wanted the file to be self sufficient so as if i mail this file to some one who does not have access to the shared network should be able to see the animation.
Is there a way it can be done.
Or is there a code to paste the .gif file from the file to desktop when the file opens.... an the path would be to the desktop.
 

bjurney

Active Member
Joined
Aug 24, 2009
Messages
320
Instead of using a webbrowser you can use an image control box from the Contorls Toolbox. Under the properties section click on Picture and choose the little option box to find your file. I dont know if this will keep your.gif animated though, I havent ever tried honestly.


Another edit:

Would it be possible for you to add the .gif to a website somewhere and then have the webbrowser navigate to the URL?
 
Last edited:

cds9892745745

New Member
Joined
Sep 2, 2009
Messages
9

ADVERTISEMENT

Hey
I tried using the Image control, It shows the Image but no animation.
Any other way it can be done
 

bjurney

Active Member
Joined
Aug 24, 2009
Messages
320
Would it be possible for you to add the .gif to a website somewhere and then have the webbrowser navigate to the URL? <!-- / message --><!-- edit note -->
 

cds9892745745

New Member
Joined
Sep 2, 2009
Messages
9

ADVERTISEMENT

No i cant put this .gif file on a website. again all users of this file may not have access to the internet.
Can we make the file to use some of microsoft animations which is there in all PC's
wat do you think
 

bjurney

Active Member
Joined
Aug 24, 2009
Messages
320
You could paste the .gif into your workbook and hide it near the bottom, or make it invisible. Then add this code to the Thisworkbook

Code:
Private Sub Workbook_Open()
Dim appwd As Object
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 3
waitTime = TimeSerial(newHour, newMinute, newSecond)
       On Error GoTo notloaded
       Set appwd = GetObject(, "Word.Application")
       
notloaded:
       If Err.Number = 429 Then
       
           Set appwd = CreateObject("Word.Application")
       End If
       appwd.Visible = True
     On Error GoTo 0

   appwd.documents.Add
   AppActivate ("Microsoft Excel")
   Worksheets("Sheet1").Shapes("Picture 1").Copy
   AppActivate ("Microsoft Word")
appwd.Selection.PasteAndFormat (wdPasteDefault)
Application.Wait waitTime
appwd.ChangeFileOpenDirectory "C:\"
appwd.ActiveDocument.SaveAs Filename:="Doc1.htm", FileFormat:=wdformatHTML, _
        LockComments:=False, Password:="", AddToRecentFiles:=False, WritePassword _
        :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
        SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
        False
End Sub

This will save the .gif file from excel into word and save it as a html file into the C: drive of the users computer. You may want to modify the code to turn off screen updating so the user doesnt see all of it happening. You could also have the code close out word and then focus back on to excel. Once you have it to your liking, add this code to your userform


Code:
Private Sub UserForm_Initialize()
WebBrowser1.Navigate2 ("C:\Doc1.htm")
End Sub

this seemed to work for me using 2007 so I dont know what results you will have if you are using another version of excel.

Best of luck!
 

cds9892745745

New Member
Joined
Sep 2, 2009
Messages
9
Hey One problem Here.
I am using Google Chrome
When the above code saves the file to C:\ , the file is saved is .htm format however file properties says it can be opened by Chrome and even the icon for the file is of Google Chrome.
If i change this manually by doing a save as and save the file as a web page on the same location then it works fine.
But i couldn't find the reason for the google chrome file ???
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,133,425
Messages
5,658,725
Members
418,466
Latest member
lisamck

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
Top