Excel VBA to Open Office code

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Open_the_Office
Posts: 2
Joined: Mon Aug 14, 2017 1:19 pm

Excel VBA to Open Office code

Post by Open_the_Office »

Hello,

I fail to convert this excel macro to open office and would be happy if somebody can help me. This macro checks automatically the prices from ebay products.
Can somebody tell me, if it is possible in Open Office, to excess web pages and extract info's?

Code: Select all

Sub Get_eBay_Product() 
    'Macro to extract Product Details from eBay shopping website for single product
    'Author     : Raghu Ram Alla
    'Date       : March 19, 2015
    'Website    : http://www.QuadExcel.com
    Dim xmlHttp As Object
    Set xmlHttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
    iRow = 5:       iCol = 1
    
    URL = Wks_eBay_Prod.Range("ProdURL").Value
    xmlHttp.Open "GET", URL, False
    xmlHttp.setRequestHeader "Content-Type", "text/xml"
    xmlHttp.send

    Dim html As Object
    Set html = CreateObject("htmlfile")
    html.body.innerHTML = xmlHttp.responseText
    
    'Item Condition
    Set objShipping = html.getElementById("vi-itm-cond")
    If Not objShipping Is Nothing Then
        Wks_eBay_Prod.Cells(iRow, iCol).Value = objShipping.innerText
    End If
    iCol = iCol + 1
    
    'Product Name
    Set objShipping = html.getElementById("vi-lkhdr-itmTitl")
    If Not objShipping Is Nothing Then
        Wks_eBay_Prod.Cells(iRow, iCol).Value = objShipping.innerText
    End If
    iCol = iCol + 1
    
    'Price
    Set objShipping = html.getElementById("prcIsum")
    If Not objShipping Is Nothing Then
        Wks_eBay_Prod.Cells(iRow, iCol).Value = objShipping.innerText
    End If
    iCol = iCol + 1
    
    'Shipping
    Set objShipping = html.getElementById("shippingSection").getElementsByTagName("td")(0)
    If Not objShipping Is Nothing Then
        Set divShip = objShipping.ChildNodes(1)
        Wks_eBay_Prod.Cells(iRow, iCol).Value = divShip.innerHTML
    End If
End Sub
Last edited by RoryOF on Mon Aug 14, 2017 2:01 pm, edited 1 time in total.
Reason: Added [Code] tags [RoryOF, Moderator]
OpenOffice 4.1 on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Excel VBA to Open Office code

Post by Villeroy »

Stick with Excel to run that code or write your own program that interfaces with OpenOffice or pay someone to do so.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
kiloran
Posts: 36
Joined: Sun Oct 14, 2012 2:06 pm

Re: Excel VBA to Open Office code

Post by kiloran »

It's certainly possible to extract web page info with OpenOffice Basic, though it's not as nice as Excel VBA. If you use Python macros with OpenOffice, there's no limit to what you can do, it's excellent.
--kiloran
LibreOffice 6 on Windows 10 and Linux Mint
User avatar
Zizi64
Volunteer
Posts: 11359
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Excel VBA to Open Office code

Post by Zizi64 »

Code: Select all

    URL = Wks_eBay_Prod.Range("ProdURL").Value
Please give us more details:

What is the Wks_eBay_Prod? Is it a Sheet in the actual/another spreadsheet document?
What is the .Range("ProdURL")? Is it a Named range on the sheet?


Can you upload your sample spreadsheet file here?


Maybe the LibreOffice can run your macros with the option "VBAsupport 1", because the LO has a littlebit higher competibility with the foreign file formats and the VBA. (I just tried it, but I got an error message at the quoted code line.)
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Open_the_Office
Posts: 2
Joined: Mon Aug 14, 2017 1:19 pm

Re: Excel VBA to Open Office code

Post by Open_the_Office »

Hello,
this is the complete file.
Attachments
Extract_eBay_Product_Details Upwork.xlsm
(20.29 KiB) Downloaded 269 times
OpenOffice 4.1 on Windows 10
Post Reply