Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Excel URL in cell, How to read it into VFP
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01250060
Message ID:
01250313
Views:
30
Not sure if u resolved this, but this very rough code below does show the URL address stored in the cells of the xls file i created in the second code sample. This is with Excel97 SR-2. Was getting the same errors u encountered trying to use the other 'Item' syntax.

Extract the URLs from the cells...
oExcel = CREATEOBJECT("Excel.Application")

oWorkbook = oExcel.Workbooks.Open("C:\temp\xlstest.xls")
oRange = oExcel.ActiveSheet.Range("B1:B63")

WITH oExcel.ActiveSheet
   FOR nRow = 1 TO oRange.Rows.Count
      oRange.Cells(nRow,2)
      IF TYPE(".Hyperlinks(nRow)") = "O"
         ? .Hyperlinks(nRow).address
      ENDIF
   ENDFOR
ENDWITH
RETURN
Create the XLS storing urls in the cells...
oExcel = CREATEOBJECT("Excel.Application")
oExcel.SheetsInNewWorkbook =  1
oWorkbook = oExcel.Workbooks.ADD()
oWorkbook.Sheets("Sheet1").NAME = "Appendix"

*--- set up column headers
*---
WITH oExcel.ActiveSheet
   .RANGE("A1").VALUE = "Table"
   .RANGE("B1").VALUE = "Hyperlink"
    oRange = .RANGE("A2:AB2")
ENDWITH

WAIT WINDOW "Writing to excel file..." NOWAIT
SELECT fcfiles
GO TOP
nCnt = 0
SCAN
   nCnt = nCnt + 1
   WITH oRange
      .COLUMNS[1].VALUE = fcfiles.fi_table
      lcPicFile = "http://www.yahoo"+ALLTRIM(STR(nCnt))+".com"
      .COLUMNS[2].Hyperlinks.Add(.columns[2], lcPicFile) 
        
      WAIT WINDOW .columns[2].Hyperlinks.Item(1).Address NOWAIT
        
   ENDWITH
   *--- move range down one row
   *---
   oRange = oRange.Offset(1,0)
ENDSCAN
oExcel.visible = .t.
oWorkbook.SAVEAS("C:\temp\xlstest.xls")
oExcel.QUIT()
RELEASE oExcel
>I have hyperlinks in a cell I have to read into a vfp field. The opposite of what you are doing
>Thanks
>
>Peter
>
>>Peter, we use the following to create an excel hyperlink to a "local" picture. We assume that the pics are located with the xls file because was are shipping all files on a CD.
>>
>>
>>*--- This will create a hyperlink of the
>>*---    photo filename if a filename is present.
>>*---
>>IF ! EMPTY(temp.fp_file)
>>   lcPicFile = ALLTRIM(temp.fp_file) + ".jpg"
>>  .COLUMNS[15].Hyperlinks.Add(.columns[15], lcPicFile)
>>ELSE
>>  .COLUMNS[15].VALUE = fp_file          && Photo Name
>>ENDIF
>>
>>
>>
>>
>>>>Try
>>>>
>>>>oSheet.Range("O141").Item(1).Hyperlinks.Item(1).Address
>>>>
>>>>
>>>>>I have an Excel sheet which stores amont other things URL to web sites
>>>>>They show a ball like picture and whren you click on it IE navigates to the site
>>>>>
>>>>
>>>
>>>I get this error:
>>>
>>>member ITEM does not evaluate to an object
>>>
>>>peter
Previous
Reply
Map
View

Click here to load this message in the networking platform