Excel SaveAs not working

Excel SaveAs not working

Postby cdmmaui » Thu Jul 05, 2018 6:56 am

Hello,

I am trying to create an automated XLS report and e-mail from FWH (18.02) . However, when I use SAVEAS, I get the following error. I have provided code and hope someone can assist.

I am getting error from Windows 10 and Windows Server 2012

Application
===========
Path and name: C:\web\cofc\5day.exe (32 bits)
Size: 3,891,200 bytes
Compiler version: Harbour 3.2.0dev (r1801051438)
FiveWin version: FWH 18.02
C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
Windows version: 6.2, Build 9200

Time from start: 0 hours 0 mins 0 secs
Error occurred at: 07/05/2018, 01:47:24
Error description: Error BASE/1004 No exported method: SAVEAS
Args:
[ 1] = U
[ 2] = C c:\apps\reports\999720180705014724.XLS

****************************
Source Code:
TRY
oExcel := GetActiveObject( "Excel.Application" )
CATCH
TRY
oExcel := CreateObject( "Excel.Application" )
CATCH
RETURN
END
END
nPage := 1
nRow := 1
oBook := oExcel:WorkBooks:Add()
oAS := oBook:Worksheets(1)
oAs:Name := 'REPORT'
oAS:Cells:Font:Name := "Arial"
oAS:Cells:Font:Size := 10
oAs:PageSetup:PrintGridLines := .F.
oAs:PageSetup:Orientation := 2

oAs:PageSetup:LeftMargin := .50
oAs:PageSetup:RightMargin := .50
oAs:PageSetup:TopMargin := .50
oAs:PageSetup:BottomMargin := .50
oAs:PageSetup:FitToPagesWide := 1
oAs:PageSetup:FitToPagesTall := .F.

oAs:Columns(01):ColumnWidth = 10 //
nRow := 1

oAs:Cells (nRow, 1):Font:Bold := .T.
oAs:Cells (nRow, 1):Font:Size := 12
oAs:Cells (nRow, 1):Value := 'TEST'
nRow++

oAs:Cells (nRow, 1):Font:Bold := .T.
oAs:Cells (nRow, 1):Font:Size := 12
oAs:Cells (nRow, 1):Value := 'Test Report'
nRow++

oAs:Cells (nRow, 1):Font:Bold := .T.
oAs:Cells (nRow, 1):Font:Size := 12
oAs:Cells (nRow, 1):Value := CHR(39) + 'Report Date = ' + DTOC( DATE() ) + ' @ ' + LEFT( TIME(), 5 )
nRow++
nRow++

// Header...
oAs:Cells (nRow, 1):Value := 'data col1.'

oAs:Cells(nRow, 1 ):Select()
nRow++
lFirst := .F.
ENDIF

// Write to XLS
oAs:Cells (nRow, 1):Value := CHR(39) + ALLTRIM( ctnrreq->reqno ) + IF(ctnrreq->cancel,"*","")
nRow++

// Counter....
nKey++

SELECT ctnrreq
SKIP
ENDDO
cCsvname := ALLTRIM( customer->recorid ) + DTOS(DATE()) + LEFT(TIME(),2)+SUBSTR(TIME(),4,2)+RIGHT(TIME(),2) + ".XLSX"
oBook:SaveAs( cRoot + cCsvname )
oExcel:Quit()
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Excel SaveAs not working

Postby Antonio Mart. » Thu Jul 05, 2018 12:24 pm

Hi,

Wellcome to ole corruption structures world (my definition)

Please, look at:

https://groups.google.com/d/msg/harbour ... QvLs0aAQAJ
viewtopic.php?f=3&t=35201#p209510
viewtopic.php?f=3&t=34154&start=0

Regards

tags. ole structures corruption error.
Antonio Mart.
 
Posts: 174
Joined: Sat Feb 23, 2013 10:04 am

Re: Excel SaveAs not working

Postby Marc Vanzegbroeck » Thu Jul 05, 2018 8:31 pm

Darrell,

You need to use
Code: Select all  Expand view
oAs:SaveAs( cRoot + cCsvname )
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 79 guests