Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To 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 December 8th, 2009, 07:31 AM
Registered User
 
Join Date: Dec 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Cool Edit Excel in VB6

I have no problem Opening an Excel spreadsheet and edit what ever I want. The problem is: If I try to add data to the Excel open spreadsheet the current code opens and another instance of Excel - soon my taskbar is full in Excel. How can I just append the new data or save, close and open the selected Excel spreadsheet.
 
Old December 8th, 2009, 08:19 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

There is some problem with your code. IT would be better if you can post the snippet here.

You can try for searching Workbooks.Open etc and fix it

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
 
Old December 8th, 2009, 10:58 AM
Registered User
 
Join Date: Dec 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Cool

My Code is in Stars

**************
...
Set ApExcel = CreateObject("Excel.application") 'Creates an object
ApExcel.Visible = True ' So you can see Excel
ApExcel.Workbooks.Open theformpath '
End If
' ==========================

For i = 1 To ListView1.ListItems.Count
rdoRS.MoveFirst
Do While rdoRS.EOF = False
hx = rdoRS!hxfield & "_" & rdoRS!Prefix
If hx = ListView1.ListItems(i).Text Then
ApExcel.Range(hx).Formula = ListView1.ListItems(i).SubItems(1)
Exit Do
End If
rdoRS.MoveNext
Loop
**************
 
Old December 8th, 2009, 10:33 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

Can you place a break point on the following line and check if it is executed more than once

Set ApExcel = CreateObject("Excel.application") 'Creates an object

Also the Range you have declared can be more explicit

Set ApExcel = CreateObject("Excel.application") 'Creates an object
Set ApXLWorkbook = ApExcel.Workbooks.Open theformpath
Set ApXLSheet = ApXLWorkbook.sheets(1)

and use the following for ranges

ApXLSheet.Range(hx).Formula = ListView1.ListItems(i).SubItems(1)

instead of

ApExcel.Range(hx).Formula = ListView1.ListItems(i).SubItems(1)

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
 
Old December 9th, 2009, 01:34 AM
Registered User
 
Join Date: Dec 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Thanks

Shasur

I found this bit of code
***********
Dim appExcel As Excel.Application
On Error Resume Next
Set appExcel = GetObject(,"Excel.Application")
IF appExcel Is Nothing Then 'No instance of Excel is available
Set appExcel = CreateObject("Excel.Application")
End If
***********

That works for me - I don't know what I am doing - I just works.

Thanks for the other input I will surely use it.

I am moving away from VB6 and looking for another development app similar to VB6 but not microsoft - any ideas?

Hornet 28
 
Old December 9th, 2009, 05:24 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Since you are working with Excel etc, it would be better if you go for .NET. In .NET you have VSTO (Visual Studio Tools for Office), which does all VBA is doing now. You can build apps in VSTO (it will combine the functionality of Office and .NET)
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
 
Old December 9th, 2009, 08:54 AM
Registered User
 
Join Date: Dec 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Smile Thanks

Shasur

I have a much broader scope in mind...than Excel. The code is just a simple 'Proof of Concept'.

I am avoiding microsoft - but - I am looking for results. I am Leaning toward a more Open environment, so to speak - even running under a small Unix kernel and avoid an OS that I do not control. Much more do do...

You have been a great help, Thanks.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Edit Access Table in Excel (2003) kewldude_3001 Access 0 April 10th, 2008 02:26 PM
Excel sheet accessing(edit/update) in asp.net hemant.dna ASP.NET 1.0 and 1.1 Basics 0 January 31st, 2007 07:37 AM
how to avoid edit of inserted data in Excel? kotaiah Excel VBA 3 September 14th, 2006 01:49 AM
VB6- Crystal Reports X, Edit a Graph at runtime irmorales VB Components 0 August 24th, 2006 01:31 PM
How can i open Excel From VB6 chiefouko Beginning VB 6 1 June 30th, 2003 08:28 AM





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