Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 28th, 2006, 01:07 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 180
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via ICQ to dpkbahuguna Send a message via MSN to dpkbahuguna Send a message via Yahoo to dpkbahuguna
Default Excel object Error

Run time Error - '1004'
Application-defined or object defined error


exception raising in this expression.

 ExcelSht.Range("c" & Trim(Str(Cnt1))).AddComment StrComment


can anyone help me...
Thanks.....

DPK..
__________________
DPK..
 
Old July 28th, 2006, 10:24 AM
Authorized User
 
Join Date: Jul 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I received no errors using the following code

Code:
Dim oExcel As New Excel.Application
oExcel.Workbooks.Add
oExcel.Visible = False
oExcel.DisplayAlerts = False
Dim cnt1 As Integer
Dim strComment As String

cnt1 = 1
strComment = "Test Comment"
oExcel.Range("A" & Trim(Str(cnt1))).AddComment strComment
oExcel.ActiveWorkbook.SaveAs ("C:\commenttest.xls")
oExcel.Quit
What are the contents of "cnt1" ad "strComment" when you run the line?

 
Old July 29th, 2006, 05:30 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 180
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via ICQ to dpkbahuguna Send a message via MSN to dpkbahuguna Send a message via Yahoo to dpkbahuguna
Default

No no no..
actually there is no syntax problem...
this expression running twice..

 ExcelSht.Range("c" & Trim(Str(Cnt1))).AddComment StrComment

first time it is not giving any error but second time error is being raised...
i think this exception is related to ExcelSht Object.
but what?
I dont know...
can you help me?
and thanks for your reply!

DPK..
 
Old July 30th, 2006, 07:05 AM
Registered User
 
Join Date: Jul 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to shameerpathoor
Default

I AM FROM INDIA
MY DOUBT IS FROM MICROSOFT EXCEL
 HOWEXCEL CAN READ A NUMBER IN WORDS
ie, 234 AS Two Hundred and Four

 
Old July 31st, 2006, 10:17 AM
Authorized User
 
Join Date: Jul 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by dpkbahuguna
 No no no..
actually there is no syntax problem...
this expression running twice..

ExcelSht.Range("c" & Trim(Str(Cnt1))).AddComment StrComment

first time it is not giving any error but second time error is being raised...
i think this exception is related to ExcelSht Object.
but what?
I dont know...
can you help me?
and thanks for your reply!

DPK..
DPK,

you can't add a comment to a cell that already has a comment. Are you changing the value of cnt1?

For example, this gives me an error:

Code:
cnt1 = 1
For k = 1 To 5
  strComment = "Test Comment" & k
  oExcel.Range("A" & Trim(Str(cnt1))).AddComment strComment
  oExcel.ActiveWorkbook.SaveAs ("C:\commenttest.xls")
Next
oExcel.Quit
While this works fine

Code:
for k = 1 To 5
  cnt1 = k
  strComment = "Test Comment" & k
  oExcel.Range("A" & Trim(Str(cnt1))).AddComment strComment
  oExcel.ActiveWorkbook.SaveAs ("C:\commenttest.xls")
Next
oExcel.Quit
 
Old August 1st, 2006, 01:10 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 180
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via ICQ to dpkbahuguna Send a message via MSN to dpkbahuguna Send a message via Yahoo to dpkbahuguna
Default

yes I am adding a comment in such a cell which already has a comment..
so is there method to remove this comment?
because there are some conditions that I have to add the comment at the same cell which already has a commnet..

thank you very much for you continue support!

DPK..
 
Old August 1st, 2006, 08:36 AM
Authorized User
 
Join Date: Jul 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by dpkbahuguna
 yes I am adding a comment in such a cell which already has a comment..
so is there method to remove this comment?
because there are some conditions that I have to add the comment at the same cell which already has a commnet..

thank you very much for you continue support!

DPK..
Yes

Code:
oExcel.Range("c" & Trim(Str(cnt1))).ClearComments
 
Old August 2nd, 2006, 03:14 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Trim(Str(Cnt1)) is equivalent to
CStr(Cnt1)

Str() adds a leading space, CStr() does not.





Similar Threads
Thread Thread Starter Forum Replies Last Post
converting .NET error object in VB error object webnet .NET Web Services 0 February 5th, 2007 06:02 AM
Excel Object dpkbahuguna Beginning VB 6 0 January 29th, 2007 01:51 AM
Error Creating Excel Object Antony Deepak ASP.NET 1.0 and 1.1 Professional 2 August 2nd, 2006 04:21 AM
Error Occurred creating Report Object: Object does sa_moizatyahoo Classic ASP Professional 0 February 1st, 2005 10:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.