Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting
ramkumar_cpt
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.charting
Andy Pope
 
Posts: n/a
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"