Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7075453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:10:45+00:00 2026-05-28T06:10:45+00:00

When this code is executed, the src and alt are set correctly, but border

  • 0

When this code is executed, the src and alt are set correctly, but border, align, hspace and vspace produce EOleException – bad varialble type.

Is it possible to set border, align, hspace and vspace with webbrowser and if so, how?
Is there anyway to find out what the correct variable types are?

iDoc := ( WebBrowser1.Document as IHTMLDocument2 );
iDoc.execCommand( 'InsertImage', False, 0 );
iImageIndex := WebBrowser1.OleObject.Document.Images.Length - 1;
iImageFileName := ExtractFileName( iImageFilePath );
// Change the src path to a relative path 
iSrc := ChangeFilePath( iImageFilePath, '..\Images\' );
iImageTextAlternative := FormInsertImage.AlternateText1.Text;
// Set Src 
WebBrowser1.OleObject.Document.Images.Item( iImageIndex ).src := iSrc;
// Set a text alternative to the graphic 
WebBrowser1.OleObject.Document.Images.Item( iImageIndex ).Alt := iImageTextAlternative;
// Set border 
WebBrowser1.OleObject.Document.Images.Item( iImageIndex ).border := FormInsertImage.Border1.EditValue;
// Set align 
WebBrowser1.OleObject.Document.Images.Item( iImageIndex ).align := FormInsertImage.Alignment1.EditValue;
// Set hSpace 
WebBrowser1.OleObject.Document.Images.Item( iImageIndex ).hSpace := FormInsertImage.hSpace1.EditValue;
// Set vSpace 
WebBrowser1.OleObject.Document.Images.Item( iImageIndex ).vSpace := FormInsertImage.vSpace1.EditValue;

Edit – This works now…

iDocument := ( TopicWebBrowser1.Document as IHTMLDocument2 );
if Assigned( iDocument ) then
begin
  // Insert the image
  iDocument.execCommand( 'InsertImage', False, 0 );
  while TopicWebBrowser1.ReadyState < READYSTATE_COMPLETE do
    Application.ProcessMessages;
  HTMLElementCollection := ( TopicWebBrowser1.Document as IHTMLDocument2 ).images;
  iImageIndex := TopicWebBrowser1.OleObject.Document.images.Length - 1;
  HTMLImgElement := ( HTMLElementCollection.Item( iImageIndex, 0 ) as IHTMLImgElement );
  // Set the src, alt, border, align, hspace and vspace             HTMLImgElement.src := ChangeFilePath( FormInsertImage.PictureName1.Text, '..\Images\' );
  // Change the src path to a relative path 
  HTMLImgElement.alt := FormInsertImage.AlternateText1.Text;
  HTMLImgElement.border := FormInsertImage.Border1.EditValue;
  HTMLImgElement.align := FormInsertImage.Alignment1.EditValue;
  HTMLImgElement.hspace := FormInsertImage.hspace1.EditValue;
  HTMLImgElement.vspace := FormInsertImage.vspace1.EditValue;
end;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:10:46+00:00Added an answer on May 28, 2026 at 6:10 am

    Try something like this

    procedure TForm1.Button1Click(Sender: TObject);
    var
      I: Integer;
      HTMLImgElement: IHTMLImgElement;
      HTMLElementCollection: IHTMLElementCollection;
    begin
      WebBrowser1.Navigate('http://www.example.com');
      while WebBrowser1.ReadyState < READYSTATE_COMPLETE do
        Application.ProcessMessages;
    
      HTMLElementCollection := (WebBrowser1.Document as IHTMLDocument2).images;
    
      for I := 0 to HTMLElementCollection.length - 1 do
      begin
        HTMLImgElement := (HTMLElementCollection.item(I, 0) as IHTMLImgElement);
        HTMLImgElement.src := 'c:\someimage.jpg';
        HTMLImgElement.alt := 'Alternative text ...';
        HTMLImgElement.border := '5';
        HTMLImgElement.align := 'middle';
        HTMLImgElement.hspace := 5;
        HTMLImgElement.vspace := 5;
      end;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

the first time the code is executed it correctly produces: load complete but the
This code is executed by many way. When it's executed by the form button
I am getting this error on a remote server, but the same code executes
I'm trying to execute this code nmea2kml.cpp but I keep getting the following errors.
I have Js Src code that contain Jsonp api functions. Where ever this Js
This code executes handbrakecli (a command line application) and places the output into a
With doctrine if you execute this code $columns = $accountTable->getColumns(); foreach ($columns as $column)
Considering this code, can I be absolutely sure that the finally block always executes,
If I run this code, will each AppDomain execute in a different thread? ThreadPool.QueueUserWorkItem(delegate
With this code: var db = google.gears.factory.create('beta.database'); db.open('cominar'); db.execute('CREATE TABLE IF NOT EXISTS Ajax

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.