Creating web pages dynamically from XLS... will not display images...

SushiSlayer

New Member
Joined
Feb 12, 2013
Messages
3
I'm trying to use excel vba to dynamically create web pages.
One restriction I have is my images must reside in a common repository (<SERVER name> mapped as Q:/.
On my trial runs I was pointing to an img on my desktop, and yes, in true html form, the images will not display... go figure...
THE QUESTION:
Can I point to these files (desktop and/or Q:/ and have them display in the 'browser'?

my code below --- well technically not mine, but I've cited the original programmer...

Thanks!

Option Explicit

Sub CommandButton1_Click()
'
' Retrieved from http: //www .makeuseof.com/tag/basic-internet-browser-vba/
' How To Make Your Own Basic Internet Browser Using VBA
' Dated: December 14, 2011
' By: Ryan Dube
'
' This Application requires Microsoft Internet Controls references
'
' To create this feature, you’ll need to insert a command button on your sheet. Under the Developer menu, _
' click on Design Mode, and then click the ' “Insert” button. You’ll see a dropdown of controls that _
' you can add to your sheet.
'
' In this case, click the button control and place it in your sheet. Make sure there’s some data in the sheet _
' (or any sheet), that you want to output 'to a report when the button is clicked. Left click on the _
' button to select it and click “View Code“.
'
Dim objIe As Object
Dim HTML As String

'\\\\\\\\\\ The HTML CODE GOES FROM HERE AND DOWN //////////

HTML = "<HTML><TITLE>" & Sheet1.Cells(1, 1).Value & "</TITLE>" & _
"<BODY><div id='container' style='position:absolute; LEFT:5px; height:400px; top:5px; '>" & _
"" & _
"<div id='frameName' style='background-color:#FFA500;width:1240px;'>" & _
"<h1 style='margin-bottom:0;'>" & Sheet1.Cells(2, 1) & "</h1></div>" & _
"" & _
"<div id='image' ' style='background-color:#FFD700; position:absolute; TOP:45px;LEFT:2px; height:865px; width:600px;float:left;'><img src='\\202depts\TD Dept - USE THIS ONE\CaseyJones\Graphics\CompletedArt\TermsDefinitions-axis.jpg'></div>" & _
"" & _
"<div id='content' style='background-color:#EEEEEE; position:absolute; TOP:45px; LEFT:638px; height:865px; width:600px;'>" & _
"" & Sheet1.Cells(2, 3) & "</div>" & _
"" & _
"<div id='footer' style='background-color:#FFA500;clear:both;text-align:center; position:absolute; TOP:920px; width:1240px;'>" & _
"Copyright © DENSO Education & Development @ DMTN</div>" & _
"" & _
"</div></BODY></HTML>"

'////////// The HTML CODE GOES HERE AND ABOVE \\\\\\\\\\

On Error GoTo error_handler
Set objIe = CreateObject("InternetExplorer.Application")
With objIe
.Navigate "about:blank"
Do While .Busy: DoEvents: Loop
Do While .ReadyState <> 4: DoEvents: Loop
.Visible = True ' control IE interface window
' .FullScreen = 2
.StatusBar = False ' control status bar
.MenuBar = False ' control menu bar
.Toolbar = False ' control toolbar
.Document.Write HTML
End With
apiShowWindow objIe.hwnd, SW_MAXIMIZE

Set objIe = Nothing
'///
'///
Exit Sub
error_handler:
MsgBox ("Unexpected Error, I'm quitting.")
objIe.Quit
Set objIe = Nothing
End Sub
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
I finally stumbled upon the obvious...
I have to pass in the image path per the server... located in Sheet1.Cells(1, 2).Value
Sheet1.Cells(2, 2).Value contains the image name
HTML(1) represents an array...

Thanks for looking, sometime you just need to step away to see a little more clearly...

r/s,
SS

<!--
HTML(1) = "<HTML><TITLE>" & Sheet1.Cells(1, 1).Value & "</TITLE>" & _
"<BODY><div id='container' style='position:absolute; LEFT:5px; height:400px; top:5px; '>" & _
"<div id='frameName' style='background-color:#FFA500;width:1240px;'>" & _
"<h1 style='margin-bottom:0;'>" & Sheet1.Cells(2, 1) & "</h1>" & _
"</div>" & _
"<div id='image' style='background-color:#FFD700; position:absolute; TOP:45px;LEFT:2px; height:865px; width:600px;float:left'>" & _
"<img src='" & Sheet1.Cells(1, 2).Value & Sheet1.Cells(2, 2).Value & ".jpg'>" & _
"</div>" & _
"<div id='content' style='background-color:#EEEEEE; position:absolute; TOP:45px; LEFT:638px; height:865px; width:600px;'>" & _
"" & Sheet1.Cells(2, 3) & "" & _
"</div>" & _
"<div id='footer' style='background-color:#FFA500;clear:both;text-align:center; position:absolute; TOP:920px; width:1240px;'>" & _
"Copyright © DENSO Education & Development @ DMTN" & _
"</div>" & _
"</div>" & _
"</BODY>" & _
"</HTML>"
-->
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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