Note that there are some explanatory texts on larger screens.

plurals
  1. POTry to display image from html using excel vba
    primarykey
    data
    text
    <p>i am working in excel vba. i want to insert an image in html using excel vba. but it doesn't show the image.</p> <pre><code>PlyrName="Me" PlyrPicLoc = "C:\EP\Player Image\asdf1234567894.jpg" HTML = "&lt;!DOCTYPE html&gt;" &amp; _ "&lt;html&gt;" &amp; _ "&lt;head&gt;" &amp; _ "&lt;title&gt;" &amp; PlyrName &amp; "'s Profile" &amp; "&lt;/title&gt;" &amp; _ "&lt;/head&gt;" &amp; _ "&lt;body&gt;" &amp; _ "&lt;img src=" &amp; PlyrPicLoc &amp; " height='150' width='150'&gt;" &amp; _ "&lt;/body&gt;" &amp; _ "&lt;/html"&gt; Set objIE = CreateObject("InternetExplorer.Application") With objIE .Navigate "about:blank" Do While .Busy: DoEvents: Loop Do While .ReadyState &lt;&gt; 4: DoEvents: Loop .Visible = True .Document.Write HTML End With Set objIE = Nothing </code></pre> <p><strong>UPDATE LAST AUGSUST 22 2013</strong></p> <p>guyz it's working if im going to use the original picture that came from the web or i made it from adobe/snip but the problem is if that picture is only copied from original one and save it to EP\Player Image Folder using this code. it's not displaying. maybe there's something wrong wtih my code on copying?</p> <pre><code>Private Sub cmdinsertpic_Click() Dim fd As FileDialog Dim objfl As Variant Dim msg Set fd = Application.FileDialog(msoFileDialogFilePicker) With fd .ButtonName = "Select" .AllowMultiSelect = False .Filters.Add "Image Files", "*.jpg;*.gif;*.bmp", 1 .Title = "Choose Player's image" .InitialView = msoFileDialogViewDetails .Show For Each objfl In .SelectedItems FilNam = objfl Image1.Picture = LoadPicture(objfl) 'Picturebox1.Image = Image.FromFile(OpenFileDalog.Filename) Next objfl On Error GoTo 0 End With 'THIS WILL COPY THE PICTURE TO EP\Player Image Folder NameFile = Application.ThisWorkbook.Path &amp; "\Player Image\" &amp; Trim(txtnewplayername.Value &amp; txtnewmc.Value) &amp; ".gif" Call SavePicture(Image1.Picture, NameFile) Set fd = Nothing End Sub </code></pre> <p>For example i copied that orignal picture and name it as <strong>asdf1234567894.gif</strong> and will save to EP\Player Image Folder</p> <pre><code>Private Sub LoadPic_Click() Dim objIE As SHDocVw.InternetExplorer PlyrPicLoc = "file:///C:/EP/Player%20Image/asdf1234567894.gif" Const PlyrNames = "Me" Dim FSObj As Scripting.FileSystemObject Dim TStream As Scripting.TextStream sPATH = "C:\EP\sample.html" sURL = "C:/EP/sample.html" shtml = "&lt;body&gt;" &amp; _ "&lt;title&gt;" &amp; PlyrNames &amp; "'s Profile" &amp; "&lt;/title&gt;" &amp; _ "&lt;img src=" &amp; Chr(34) &amp; PlyrPicLoc &amp; Chr(34) &amp; " height='150' width='150'&gt;" &amp; _ "&lt;body&gt;" &amp; _ "&lt;/body&gt;" &amp; _ "&lt;/html&gt;" Set FSObj = New Scripting.FileSystemObject Set TStream = FSObj.CreateTextFile(sPATH, True) TStream.WriteLine (shtml) TStream.Close Set objIE = CreateObject("InternetExplorer.Application") With objIE .Navigate sURL Do While .Busy: DoEvents: Loop Do While .ReadyState &lt;&gt; 4: DoEvents: Loop .Visible = True End With Set objIE = Nothing Set FSObj = Nothing Set TStream = Nothing End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload