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:
 

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
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
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:

Forum statistics

Threads
1,081,832
Messages
5,361,586
Members
400,639
Latest member
fleyd

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top