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