2 Respuestas
AldoB
Use Internet Explorer
Method #1 - Using HyperlinkToURL function
Needs PB6.5 or better. Starts the default browser as defined in your installation. string ls_url
inet iinet_base
ls_url = "http://wwww.server.com/myWebApp?file=error.log"
GetContextService("Internet", iinet_base)
iinet_base.HyperlinkToURL(ls_url)
Method #2 - Using OLEObject InternetExplorer.Application + Run OLEObject IE
string ls_ie
string ls_url
IE = CREATE OLEObject
IE.ConnectToNewObject("InternetExplorer.Application")
ls_ie = IE.Fullname ()
ls_url = "http://wwww.server.com/myWebApp?file=error.log"
Run (ls_ie + " " + ls_url)
Method #3 - Using OLEObject InternetExplorer.Application
Provides complete control IE behaviour. OLEObject IE
IE = CREATE OLEObject
IE.ConnectToNewObject("InternetExplorer.Application")
IE.left=200
IE.top=200
IE.height=400
IE.width=400
IE.menubar=0
IE.toolbar=1
IE.statusBar=0
IE.navigate("http://wwww.server.com/myWebApp?file=error.log")
IE.visible=1
// Local external function decalration
// FUNCTION boolean SetForegroundWindow( long hWnd ) LIBRARY "USER32"
SetForegroundWindow( IE.HWND )
Method 4 - Using OLEObject InternetExplorer.Application
Provides complete control IE behaviour. You simulate a FORM submit.using the POST method. OLEObject IE
IE = CREATE OLEObject
IE.ConnectToNewObject("InternetExplorer.Application")
IE.left=200
IE.top=200
IE.height=400
IE.width=400
IE.menubar=0
IE.toolbar=1
IE.statusBar=0
IE.goHome
IE.visible=1
DO WHILE IE.busy
LOOP
IE.document.Open
IE.document.WriteLn("<HTML><HEAD>")
IE.document.WriteLn("<SCRIPT>")
IE.document.WriteLn("function go() {")
IE.document.WriteLn(" document.myform.submit()")
IE.document.WriteLn(" }")
IE.document.WriteLn("</SCRIPT>")
IE.document.WriteLn("</HEAD>")
IE.document.WriteLn("<BODY onload='go()'>")
IE.document.WriteLn("<FORM name='form' METHOD='GET' ACTION='http://server.com/myApp'>")
IE.document.WriteLn("<INPUT NAME='file' TYPE=HIDDEN VALUE='error.log'>")
IE.document.WriteLn("</FORM>")
IE.document.WriteLn("</BODY>")
IE.document.WriteLn("</HTML>")
IE.document.Close
// Local external function declaration
// FUNCTION boolean SetForegroundWindow( long hWnd ) LIBRARY "USER32"
SetForegroundWindow( IE.HWND )
// IE.Quit()
// IE.DisconnectObject()
// DESTROY iBrowser
--------------------------------------------------------------------------------
Some tips from rkern (thanks to him!).
Some handy properties: IE.top = <integer>
IE.left = <integer>
IE.width = <integer>
IE.height = <integer>
IE.visible = <integer> (1 - Visible/ 0 - Not Visible)
IE.menuBar = <integer> (1 - Visible/ 0 - Not Visible)
IE.toolBar = <integer> (1 - Visible/ 0 - Not Visible)
IE.statusBar = <integer> (1 - Visible/ 0 - Not Visible)
Go To a URL: string ls_OldURL
string ls_NewURL = 'www.yahoo.com'
// Go to Document
ls_OldURL = IE.LocationURL
IE.Navigate (ls_NewURL)
// Wait for Document to start loading
DO WHILE ls_OldURL = IE.LocationURL
Yield ()
LOOP
// Wait for Document to finish Loading
DO WHILE IE.Busy
Yield ()
LOOP
Notes:
-The Busy attribute does not always get set immediateley so wait for URL to change before checking the Busy attribute
- This method works as long as the OldURL and NewURL are not the same
Click on a Link with a specific display text: integer li_link, li_link_ctr
string ls_text, ls_OldURL, ls_search = 'Download Spreadsheet'
// Set Match string
ls_search = Upper(ls_search)
// Find Link with specified Text
li_link_ctr = IE.Document.Links.Length
FOR li_link = 0 TO li_link_ctr - 1
ls_Text = Upper(IE.Document.Links[li_link].InnerText)
// Check for Match
IF ls_Text = as_Search THEN
// Click the Link
ls_OldURL = IE.LocationURL
IE.Document.Links[li_link].Click()
// Wait for Document to start loading
DO WHILE ls_OldURL = IE.LocationURL
Yield ()
LOOP
// Wait for Document to finish loading
DO WHILE IE.Busy
Yield ()
LOOP
EXIT
END IF
NEXT
Notes:
- The Busy attribute does not always get set immediateley so wait for URL to change before checking the Busy attribute
- This method works as long as the OldURL and NewURL are not the same - Unlike PB, arrays start at index = 0 to length - 1 - Use attribute HRef if you want to match on a URL
Click on a Button with a specific display text: integer li_form, li_form_ctr
integer li_elem, li_elem_ctr
boolean lb_stop
string ls_text, ls_OldURL, ls_search = 'Search'
any la_name, la_type, la_value
// Set Match string
ls_search = Upper(ls_search)
// Search thru Forms
li_form_ctr = IE.Document.Forms.Length
FOR li_form = 0 TO li_form_ctr - 1
// Search thru Elements
li_elem_ctr = IE.Document.Forms[li_form].Elements.All.Length
FOR li_elem = 0 TO li_elem_ctr - 1
la_Name =
IE.Document.Forms[li_form].Elements.All[li_elem].GetAttribute("name")
la_Type =
IE.Document.Forms[li_form].Elements.All[li_elem].GetAttribute("type")
la_Value =
IE.Document.Forms[li_form].Elements.All[li_elem].GetAttribute("value")
CHOOSE CASE Upper(String(la_Type))
CASE 'SUBMIT', 'RESET', 'BUTTON'
ls_Text = Upper(String(la_Value))
// Check for Match
IF ls_Text = ls_Search THEN
// Click the Button
ls_OldURL = IE.LocationURL
IE.Document.Forms[li_form].Elements.All[li_elem].Click()
// Wait for Document to start loading
DO WHILE ls_OldURL = IE.LocationURL
Yield ()
LOOP
// Wait for Document to finish loading
DO WHILE IE.Busy
Yield ()
LOOP
lb_Stop = TRUE
EXIT
END IF
END CHOOSE
NEXT
IF lb_Stop THEN
EXIT
END IF
NEXT
Notes:
- The Busy attribute does not always get set immediateley so wait for URL to change before checking the Busy attribute
- This method works as long as the OldURL and NewURL are not the same
- Unlike PB, arrays start at index = 0 to length - 1
- Use attribute Name if you want to match on an internal HTML Name
- The Returned Values of the GetAttribute method must be ANY variables, even though they return STRINGS
Fill in a Input Field that has a specific Name: integer li_form, li_form_ctr
integer li_elem, li_elem_ctr
boolean lb_Stop
string ls_text, ls_search = 'Company'
any la_name, la_type, la_value
// Set Match string
ls_search = Upper(ls_search)
// Search thru Forms
li_form_ctr = IE.Document.Forms.Length
FOR li_form = 0 TO li_form_ctr - 1
// Search thru Elements
li_elem_ctr = IE.Document.Forms[li_form].Elements.All.Length
FOR li_elem = 0 TO li_elem_ctr - 1
la_Name =
IE.Document.Forms[li_form].Elements.All[li_elem].getAttribute("name")
la_Type =
IE.Document.Forms[li_form].Elements.All[li_elem].getAttribute("type")
la_Value =
IE.Document.Forms[li_form].Elements.All[li_elem].getAttribute("value")
// ls_Text = IE.Document.Forms[li_form].Elements.All[li_elem].InnerText
CHOOSE CASE Upper(String(la_Type))
CASE 'TEXT', 'TEXTAREA', 'PASSWORD'
ls_Text = Upper(String(la_Name))
// Check for Match
IF ls_Text = ls_Search THEN
// Set the value
IE.Document.Forms[li_form].Elements.All[li_elem].Value = ls_Value
lb_Stop = TRUE
Exit
END IF
END CHOOSE
NEXT
IF lb_Stop THEN
Exit
END IF
NEXT
Notes:
- Unlike PB, arrays start at index = 0 to length - 1
- Use attribute InnerText if you want to match on a percieved label on the field. Check each element's InnerText until a match is found and then fill in the next input field you come to (usually works).
- The Returned Values of the GetAttribute method must be ANY variables, even though they return STRINGS
- Compartir respuesta
La inserción de una página web usando OLE (Object Linking and Embedding) es un proceso que depende del software o la plataforma específica que estés utilizando. Aquí te doy un ejemplo general para insertar una página web en Microsoft Word utilizando OLE:
Abre Microsoft Word: Inicia Microsoft Word y abre el documento en el que deseas insertar la página web.
Habilita la ficha "Desarrollador" (si es necesario): Si no ves la ficha "Desarrollador" en la cinta de opciones, puedes habilitarla siguiendo estos pasos:
- Ve a "Archivo" > "Opciones".
- Selecciona "Personalizar cinta de opciones".
- Marca la casilla "Desarrollador" y haz clic en "Aceptar".
Inserta un Control WebBrowser:
- Ve a la ficha "Desarrollador".
- Haz clic en "Insertar" en el grupo "Controles".
- Selecciona "Control WebBrowser".
Configura el Control WebBrowser:
- Haz clic en el lugar del documento donde deseas insertar el control WebBrowser.
- Haz clic derecho en el control WebBrowser y selecciona "Propiedades".
- En las propiedades, busca la propiedad "Url" o "Source" (dependiendo de la versión) y especifica la URL de la página web que deseas insertar.
Guarda y Actualiza el Documento:
- Guarda el documento.
- Si el control WebBrowser no muestra la página web, cierra y vuelve a abrir el documento para asegurarte de que se cargue.
Algunos ejemplos de páginas:
https://ideaspersonalizadas.com/
https://www.quieropersonalizar.com/
Ten en cuenta que la disponibilidad de estas opciones puede variar según la versión de Microsoft Word que estés utilizando. Además, algunas configuraciones de seguridad en Word pueden impedir la carga de contenido web.
Si estás trabajando en un entorno diferente o utilizando otro software, los pasos pueden ser distintos. Por favor, proporciona más detalles sobre el entorno o el software específico para obtener instrucciones más precisas.
- Compartir respuesta