473,511 Members | 16,846 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error trying to create multiple Excel worksheets per session

121 New Member
Can I generate more than 1 Excel sheet when a command button is clicked?
For eg
I search for 2 names of audit dept and click print command button where records will be printed in Excel.
Again if I search for other 2 names and if I click print command button reports will not be printed.and gives error I have to close the program and load the program again.
If yes can you tell me how?
When I write a code when it executes or second Excel sheet it gives error
Aug 27 '07 #1
10 1948
hariharanmca
1,977 Top Contributor
can i generate more than 1 excel sheets when a command button is clicked
for eg
i search for 2 names of audit dept and click print command button where records will be printed in excel
again if i search for other 2 names and if i click print command button reports will not be printed.and gives error i have to close the program and load the program again
if yes can u tell me how.
hen i wrte a cde whenit eecutes or second exce sheet it gives error

--------------------------------------------------------------------------------
Can you explain detail?
VB Version?
you mean Report or excel sheet, then there versions?
Aug 27 '07 #2
charvi
121 New Member
Can you explain detail?
VB Version?
you mean Report or excel sheet, then there versions?
I am using VB6. I have coded in VB6 to generate an Excel sheet and put the data from Access to Excel sheet.
First time data will be placed in Excel sheet appropriately.
But again when I want to create it gives error
Object variable or with block variable not set
please help.Very urgent.
Thanks
Aug 27 '07 #3
Killer42
8,435 Recognized Expert Expert
I think we'll need to see the code. It sounds as though you have created an Excel object in your program at startup or something, then released it (Set ... = Nothing) after using it, so then you can't use it again.
Aug 27 '07 #4
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

U will have to Release all the objects related to Excel, Otherwise u will get that error, Close and Set to Nothing xlApp object and xlwrkbook/xlsheet objects..

REgards
Veena
Aug 27 '07 #5
charvi
121 New Member
I am using VB6. I have coded in VB6 to generate an Excel sheet and put the data from Access to Excel sheet.
First time data will be placed in Excel sheet appropriately.
But again when I want to create it gives error
Object variable or with block variable not set
please help.Very urgent.
Thanks

Expand|Select|Wrap|Line Numbers
  1. Dim objexcel As excel.Application
  2. Set objexcel = New excel.Application
  3. objexcel.Visible = True
  4. objexcel.SheetsInNewWorkbook = 4
  5. objexcel.Workbooks.Add
  6.  
  7.  
  8. Dim rsa As New ADODB.Recordset
  9. rsa.Open "select count(*) from temp", conn, adOpenDynamic, adLockOptimistic
  10. With rsa
  11.   Dim s As Integer
  12.   s = rsa.Fields(0)
  13.   Dim a As Integer
  14. End With
  15. rsa.Close
  16.  
  17. Dim rs As New ADODB.Recordset
  18. rs.CursorLocation = adUseClient
  19. rs.Open "select * from temp", conn, adOpenDynamic, adLockOptimistic
  20.  
  21. Dim strSQL As String
  22. Dim n As Integer
  23. Dim intcount2 As Integer
  24. intcount2 = 0
  25. intcount = 0
  26. With rs
  27.     While rs.EOF = False
  28.         If rs.Fields(0) < 7 Then
  29.             ActiveSheet.Cells(intcount + 2, 1) = !Name
  30.             ActiveSheet.Cells(intcount + 3, 1) = !Des
  31.             ActiveSheet.Cells(intcount + 4, 1) = !comp
pls help this is th code
Aug 27 '07 #6
QVeen72
1,445 Recognized Expert Top Contributor
hI,

write this code at the end:

Set objexcel = Nothing

REgards
Veena
Aug 27 '07 #7
charvi
121 New Member
hI,

write this code at the end:

Set objexcel = Nothing

REgards
Veena
write objexcel=noting
but it dos not work
Aug 27 '07 #8
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

If u already ebcountered that problem, u need to restart ur system and at the end it is "Set ObjExcel = Nothing"


REgards
Veena
Aug 27 '07 #9
charvi
121 New Member
Hi,

If u already ebcountered that problem, u need to restart ur system and at the end it is "Set ObjExcel = Nothing"


REgards
Veena
still it is not working
Aug 27 '07 #10
Killer42
8,435 Recognized Expert Expert
...ActiveSheet.Cells(intcount + 2, 1) = !Name ...
Are you sure this is VB6? I wouldn't have thought VB would understand ActiveSheet. Isn't that a VBA thing?

I don't have time to check this at the moment, sorry.
Aug 28 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

13
35485
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet...
5
8029
by: Iris | last post by:
I have 8 text files (tab delimited) that I would like to import into an Excel workbook as 8 individual worksheets but I cannot find any example code on this subject. Can anyone help me please???? ...
4
8697
by: paul.chae | last post by:
I have a table in Access with about 3000 records. There are ~60 unique values in the ID field for the 3000 records. What I would like to do is automatically generate multiple Excel worksheets...
3
3984
by: dan_roman | last post by:
Hi, I developed a script with a nice interface in Tkinter that allows me to edit some formulas and to generate an Excel worksheet with VBA macros within it. The script runs perfectlly in Office...
4
11322
by: Abdhul Saleem | last post by:
Hi, I am recieving error ActiveX component can't create object in the following line in the asp page. set ExcelApp = CreateObject("Excel.Application") Previously this code was working fine....
2
2567
by: LadyRed2 | last post by:
Hello, I am new to Excel and SQL server, so please be patient with me. I have written code with the help of others to update a table in a sql database from an excel form. The connection code...
0
1735
by: dprjessie | last post by:
Hello, I am a Web programmer and I'm working on my first desktop application as a favor for a friend. I'm sure I have a stupid error here, but there is no error being thrown so I can't figure out...
3
6224
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store...
2
3443
by: stjones1 | last post by:
My company has implementd Vista with IE7 and office 2007. We also use Sharepoint extensively for team sites and division portals. I am in Sharepoint consultation/support. One user just moved a...
0
7242
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7355
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7081
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5668
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3225
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3213
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1576
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
447
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.