Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
OLE with Excel - I'm stumped
Message
From
27/06/2003 08:15:41
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
27/06/2003 08:00:25
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00804575
Message ID:
00804609
Views:
41
>>Cetin
>>
>>Sorry but with the following code
>>
>>*Form.init
>>this._webBrowser41.Navigate2('file://c:\downloads\mertest.xls')
>>
>>
>>
>>oXLS = thisform._webbrowser41.object.document
>>
>>oExcel = oXLS.Application
>>oExcel.ActiveWorkbook.ActiveSheet.Range('E1:E7').Value = 'sheet1'
>>oExcel.Application.ActiveWorkbook.Save()
>>
>>I get the message OXLS is not an object
>>
>>I have added classes _webview, _base and _ control
>>
>>What am I missing?
>>
>>Thanks
>>
>>Colin
>
>Web view ?
>WebBrowser4 control : Tools\Component Gallery\VFP foundation classes\Internet\Web browser control.
>Cetin
oForm = Createobject('form1')
oForm.Show()
Read Events

Define Class form1 As Form
  Top = 0
  Left = 0
  Height = 470
  Width = 740
  DoCreate = .T.
  Caption = "HTML sample"
  Name = "Form1"

  * This is IE control - you'd use webbrowser4 from gallery instead
  * just because it already has some checks, extra pem. ie: wouldn't need readystate part
  * for the sake of keeping code short here I directly use olecontrol itself
  Add Object htmlviewer As OleControl With ;
    Top = 12, ;
    Left = 12, ;
    Height = 396, ;
    Width = 708, ;
    Visible = .T., ;
    Name = "HTMLViewer", ;
    OleClass = 'Shell.Explorer'

  Add Object cmdExcel As CommandButton With ;
    Height = 25, ;
    Left = 12, ;
    Top = 432, ;
    Width = 60

  Procedure Init
    lcXLSFile = 'c:\downloads\mertest.xls'
    With Thisform.htmlviewer
      .Navigate2('file://'+lcXLSFile)
      Do While .ReadyState # 4 && Wait for ready state
      Enddo
    Endwith
  Endproc

  Procedure cmdExcel.Click
    oXLS = Thisform.htmlviewer.Object.Document
    oExcel = oXLS.Application
    With oExcel.ActiveWorkbook
      .ActiveSheet.Range('E1:E7').Value = 'sheet1'
      .WorkSheets(.WorkSheets.Count).Range('E1:E7').Value = 'LastSheet'
      .Save()
      .WorkSheets(.WorkSheets.Count).Activate
    Endwith
  Endproc

  Procedure QueryUnload
    Clear Events
  Endproc
Enddefine
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform