Important alert: (current site time 7/16/2013 1:45:37 AM EDT)
 

winzip icon

__ FlexGrid control items to an Excel workbook

Email
Submitted on: 1/18/2002 2:39:14 PM
By: Frank Kusluski  
Level: Intermediate
User Rating: By 24 Users
Compatibility: VB 5.0, VB 6.0
Views: 57428
(About the author)
 
     Sample code which demonstrates how to copy items from a FlexGrid control to an Excel workbook.
 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
  3. Scan the source code with Minnow's Project Scanner

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 13 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
2/7/2002 3:37:05 AMmrsoon

Thanks pal, nice bit of work!! its very usefull, ive been struggling with this flex grid but this is a good example.

Cheers
mrsoon
(If this comment was disrespectful, please report it.)

 
3/30/2002 8:42:50 PMManas Mukherjee

very nice use of AppActivate. I read similar article in MSDN ID: Q115782, was not impressed. Excelent approach. You got 5+. Keep it up
Manas Mukherjee,Ph.D.
(If this comment was disrespectful, please report it.)

 
4/2/2002 6:01:52 PMKush

Nice piece of code there. simple and aptly demonstrates the use of Flexgrid as well as the "Excel" Object. Was really helpful.
(If this comment was disrespectful, please report it.)

 
8/23/2002 9:58:31 PM

Thank You!!! This Code ...
(If this comment was disrespectful, please report it.)

 
9/16/2002 5:28:16 AM

Pl. give me a chance to use this coding first
(If this comment was disrespectful, please report it.)

 
9/24/2002 9:52:25 AMMel Arquiza

This kind of code we need to share to every programmer who wish to grow.
Thanks a lot.
(If this comment was disrespectful, please report it.)

 
10/11/2002 8:19:43 AM

Pls, let me use this code.
(If this comment was disrespectful, please report it.)

 
11/30/2002 10:00:27 AM

Cheers this will help me greatly thank you :) well done and the rest of the ego boosting ^.^ thanks again
(If this comment was disrespectful, please report it.)

 
1/11/2003 11:50:17 AM

just i have downloaded fr the hub. pls give me a time to work out this.

Thank you
(If this comment was disrespectful, please report it.)

 
2/3/2003 6:42:02 AM

Why in task manager have excel and can'n open file excel until close program
(If this comment was disrespectful, please report it.)

 
6/5/2003 5:36:32 AM

Slight problem I've found with ExcelXP. Basically if you run this program, create the spread sheet, then close excel and try to create the spread sheet again you should find Excel opens but the workbook is missing (i.e. Excel has died).

The reason I think this happens is because of the way .NET works by flushing the trash (i.e. no longer used object ref's) sporadically rather than immediatley as objects are no longer used.

Anyway, whatever the problem, the solution is:

Dim temp as string

Set objExcel = GetObject(, "Excel.Application")
temp = ActiveSheet.Name
If Err.Number Then
Err.Clear
Set objExcel = CreateObject("Excel.Application")
If Err.Number Then
MsgBox "Can't open Excel.", vbExclamation
GoTo eh
End If
End If

As you can see after checking to see if an Excel instance already exists I immediatley check for a workbook value which would need to be present if Excel is still a valid instance.

Cheers
Mike
(If this comment was disrespectful, please report it.)

 
6/5/2003 5:37:06 AM

Only 1000 chars bah!


The only problem is that if you close the first Excel instance then create a 2nd instance , then create a 3rd without closing the secon you actually end up with 2 instances of the Excel app rather than 1 because the code is still trying to reference the no longer valid 1st instance... Not too sure if that made sense??? Have a play and you'll see what I mean.

I expect to come back here in a week and see somone has a solution to my Excel woes :)

Cheers again
Mike
(If this comment was disrespectful, please report it.)

 
10/22/2003 8:22:35 AM

Can I use this for a Datagrid also?
(If this comment was disrespectful, please report it.)

 
12/1/2003 8:59:48 PM

Thanks, your code is short but simple =)
(If this comment was disrespectful, please report it.)

 
6/13/2004 10:50:18 AMColin Jackson

Great bit of code that saved me some time digging around in an area I had to include but wasn't really interested in learning about atm. Thanks. Would have got 5 stars if it had coped with the XP Excel issue mentioned above - anybody come up with a fix (rather than the error trap above)?
(If this comment was disrespectful, please report it.)

 
7/23/2004 3:31:21 AM

Nice piece of code. It will really give other developers a new twist in developing in VB
(If this comment was disrespectful, please report it.)

 
5/10/2005 7:13:27 AM

how can i use excel code in windows 98?
how can i solve automation error?
(If this comment was disrespectful, please report it.)

 
5/10/2005 7:15:49 AM

how can i use excel code in windows 98?
how can i solve automation error?

(If this comment was disrespectful, please report it.)

 
8/15/2005 2:46:19 PMBadaru

good downloading...
(If this comment was disrespectful, please report it.)

 
5/10/2007 2:36:36 AMmitz

great job. could u help me?

(If this comment was disrespectful, please report it.)

 
2/22/2008 8:06:38 AMagus

so nice, thank so much for this source code
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.