473,791 Members | 3,179 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 1969
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

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

Similar topics

13
35565
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 and extract information from specific worksheets and cells. I'm not really sure how to get started with this process. I ran the COM Makepy utility from my PythonWin (IDE from ActiveSTate),
5
8037
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???? Thanks in advance. Regards,
4
8717
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 within a single workbook with these records. I would end up with around 500 worksheets, 1 for each unique ID value. I was thinking this could be done if I have an exported flag column in the table, and I search for the max (or min) on the ID...
3
4017
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 2000, but in Office 2003 crash at line: "wbc = workbook.VBProject.VBComponents.Add(1)" Please help me :-( the code of the module that crash is (only in Excel 2003, in 2000 not): import os
4
11338
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. Thanks in advance.
2
2580
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 works as I have used it for a query before. Here is the code Private Sub CommandButton3_Click() 'to Update or Insert new into the form
0
1753
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 what is wrong. I have code that reads an excel file and fills a datagridview and it works just fine. It is also supposed to fill a database though and that is not working. The executeNonQuery command is returning a 1 which as I understand, means it has...
3
6251
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 that multiple worksheet data in different table.How can i do it.Below is my xml file. <?xml version="1.0"?> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" ...
2
3470
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 website from our old system to sharepoint, and now one of her links is broken. It is a simple ASP page with parameters that uses VB script to create an Excel object and load an Excel file into it (wb name, sheet name, and scroll number are the ASP...
0
9512
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10419
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10201
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10147
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9987
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9023
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7531
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5552
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2910
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.