kyletreyfield
Technical User
I know there are multiple threads on this topic but no matter what I try I cannot get it to work. I am simply trying to copy some excel cells from another worksheet into my current worksheet, go to a different spot, copy another worksheet, etc.
I keep getting the error that says 'Unable to get the Paste property of the Worksheet class'
Here is my code:
oX=CreateObject("EXCEL.APPLICATION")
WITH oX
oX.Visible=.T.
oX.Workbooks.Open("c:\rfportal\combine_project\rfps\&rfpvartext\master.xlsm")
SELECT dirtable
GO TOP
DO WHILE .NOT. EOF()
oX.Run("MergeWorkbooks",TRIM(dirtable.folder))
SKIP
ENDDO
oX.ActiveWorkbook.SaveAs('c:\rfportal\combine_project\rfps\&rfpvartext\final\&final_spreadsheet')
oX.Workbooks.Open("c:\rfportal\combine_project\rfps\&rfpvartext\final\&final_spreadsheet")
oX.WINDOWS("&final_spreadsheet").ACTIVATE
SELECT these_prods
GO top
DO WHILE NOT EOF()
STORE ALLTRIM(these_prods.product) TO prodvar
STORE prodvar+".xls" TO prod_xls
oX.Sheets("&prod_xls").Select
oX.Rows("1:1").Select
oX.Selection.Delete
oX.Columns("A:A").Select
oX.Selection.Delete
oX.Rows("2:9").Select
oX.Selection.Insert
oX.Range("b2").Select
SELECT *;
from mixtable;
WHERE ALLTRIM(mixtable.product)==prodvar;
INTO CURSOR thismix
STORE RECCOUNT() TO thiscount
GO top
DO WHILE NOT EOF()
STORE ALLTRIM(thismix.ratefile) TO thisratefile
oX.Workbooks.Open("c:\rfportal\combine_project\rfps\&rfpvartext\final\rates\&thisratefile")
oX.WINDOWS("&thisratefile").ACTIVATE
loSheet = .activesheet
With loSheet
loSheet.Range("A1:A5").Copy
loSheet.Application.CutCopyMode = False
endwith
oX.Activesheet.Paste
oX.ActiveCell.Offset(0, 1).Select
SELECT thismix
SKIP
ENDDO
oX.Cells.Select
oX.Selection.Columns.AutoFit
oX.Sheets("&prod_xls").Select
oX.Sheets("&prod_xls").Name = "&prodvar"
SELECT these_prods
SKIP
ENDDO
oX.ActiveWorkbook.SaveAs('c:\rfportal\combine_project\rfps\&rfpvartext\final\final_spreadsheet2')
oX.ActiveWorkbook.Close
oX.Quit
ENDWITH
I keep getting the error that says 'Unable to get the Paste property of the Worksheet class'
Here is my code:
oX=CreateObject("EXCEL.APPLICATION")
WITH oX
oX.Visible=.T.
oX.Workbooks.Open("c:\rfportal\combine_project\rfps\&rfpvartext\master.xlsm")
SELECT dirtable
GO TOP
DO WHILE .NOT. EOF()
oX.Run("MergeWorkbooks",TRIM(dirtable.folder))
SKIP
ENDDO
oX.ActiveWorkbook.SaveAs('c:\rfportal\combine_project\rfps\&rfpvartext\final\&final_spreadsheet')
oX.Workbooks.Open("c:\rfportal\combine_project\rfps\&rfpvartext\final\&final_spreadsheet")
oX.WINDOWS("&final_spreadsheet").ACTIVATE
SELECT these_prods
GO top
DO WHILE NOT EOF()
STORE ALLTRIM(these_prods.product) TO prodvar
STORE prodvar+".xls" TO prod_xls
oX.Sheets("&prod_xls").Select
oX.Rows("1:1").Select
oX.Selection.Delete
oX.Columns("A:A").Select
oX.Selection.Delete
oX.Rows("2:9").Select
oX.Selection.Insert
oX.Range("b2").Select
SELECT *;
from mixtable;
WHERE ALLTRIM(mixtable.product)==prodvar;
INTO CURSOR thismix
STORE RECCOUNT() TO thiscount
GO top
DO WHILE NOT EOF()
STORE ALLTRIM(thismix.ratefile) TO thisratefile
oX.Workbooks.Open("c:\rfportal\combine_project\rfps\&rfpvartext\final\rates\&thisratefile")
oX.WINDOWS("&thisratefile").ACTIVATE
loSheet = .activesheet
With loSheet
loSheet.Range("A1:A5").Copy
loSheet.Application.CutCopyMode = False
endwith
oX.Activesheet.Paste
oX.ActiveCell.Offset(0, 1).Select
SELECT thismix
SKIP
ENDDO
oX.Cells.Select
oX.Selection.Columns.AutoFit
oX.Sheets("&prod_xls").Select
oX.Sheets("&prod_xls").Name = "&prodvar"
SELECT these_prods
SKIP
ENDDO
oX.ActiveWorkbook.SaveAs('c:\rfportal\combine_project\rfps\&rfpvartext\final\final_spreadsheet2')
oX.ActiveWorkbook.Close
oX.Quit
ENDWITH