Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.charting
|
|||
|
|||
Got error in Shapes.AddShape()
Got error in this statement. xlApp.Sheets(1).Shapes.AddShape(msoShapeRectangle, 60.75, 222.75, 6, 6). Its working fine in Macro. I tried run this macro code using Visual basic application. It is not working. My vb code is.. Dim xlApp As Excel.Application '// Hold reference to Excel Application Dim xlWrkbk As Excel.Workbook '// Hold reference to Full Template Excel Dim objWorkSheet As Excel.Worksheet '// Hold reference to Excel sheet Private Sub Command1_Click() 'Initialize the Excel Application Properties Set xlApp = New Excel.Application xlApp.Visible = True '// Open the Report Excel and the Full Template Excel Set xlWrkbk = xlApp.Workbooks.Open("C:\ram.xls") Set objWorkSheet = xlWrkbk.Worksheets("ProjectKPIs") '// Display the link at start page With xlApp.Sheets(1).Shapes.AddShape(msoShapeRectangle, 60.75, 222.75, 6, 6) .Fill.ForeColor.SchemeColor = 18 End With End Sub Thanks in advance Ram. -- ramkumar_cpt ------------------------------------------------------------------------ ramkumar_cpt's Profile: http://www.excelforum.com/member.php...o&userid=28673 View this thread: http://www.excelforum.com/showthread...hreadid=522536 |
#2
Posted to microsoft.public.excel.charting
|
|||
|
|||
Got error in Shapes.AddShape()
Hi,
You need to reference the workbook. Also the Fill command needs a referencing dot added. With xlWrkbk.Sheets(1).Shapes.AddShape( _ msoShapeRectangle, 60.75,222.75, 6, 6) .Fill.ForeColor.SchemeColor = 18 End With Cheers Andy ramkumar_cpt wrote: Got error in this statement. xlApp.Sheets(1).Shapes.AddShape(msoShapeRectangle, 60.75, 222.75, 6, 6). Its working fine in Macro. I tried run this macro code using Visual basic application. It is not working. My vb code is.. Dim xlApp As Excel.Application '// Hold reference to Excel Application Dim xlWrkbk As Excel.Workbook '// Hold reference to Full Template Excel Dim objWorkSheet As Excel.Worksheet '// Hold reference to Excel sheet Private Sub Command1_Click() 'Initialize the Excel Application Properties Set xlApp = New Excel.Application xlApp.Visible = True '// Open the Report Excel and the Full Template Excel Set xlWrkbk = xlApp.Workbooks.Open("C:\ram.xls") Set objWorkSheet = xlWrkbk.Worksheets("ProjectKPIs") '// Display the link at start page With xlApp.Sheets(1).Shapes.AddShape(msoShapeRectangle, 60.75, 222.75, 6, 6) Fill.ForeColor.SchemeColor = 18 End With End Sub Thanks in advance Ram. -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|