|
-
Nov 4th, 2009, 12:35 AM
#1
Thread Starter
Frenzied Member
Opening Excel when click at BtPrint_click()
Can anybody tell me .Why excel is not comming .When user click On BtPrint_click.Kindly let me know the idea.Any help would be highly appreciated.here is the following code what i have written.
Code:
Private Sub btPrint_Click()
Dim excl As Excel.Application
Set excl = New Excel.Application
' Set excl = CreateObject(Excel.Application)
excl.Visible = True
Set excl = Nothing
End Sub
Last edited by firoz.raj; Nov 4th, 2009 at 12:43 AM.
-
Nov 4th, 2009, 12:42 AM
#2
Re: Opening Excel when click at BtPrint_click()
Because you are closing it the moment you are creating it...
Set excl = Nothing
I suggest that you read the tutorial by Si here
http://www.vbforums.com/showthread.php?t=391665
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Nov 4th, 2009, 03:58 AM
#3
Thread Starter
Frenzied Member
Re: Opening Excel when click at BtPrint_click()
i need to know step by step.why it is not working .right know i did comment this line set excl=Nothing.but still it is not working .additional i want to address each cell Through Vbcode to make Purchase order.So that excel report should come automatically.Kindly let me know the idea.why even excel is not comming .it is comming and going automatic.it should not stay at the screen.Kindly let me know the idea.Any help would be highly appreciated.
Code:
Private Sub btPrint_Click()
Dim excl As Excel.Application
Set excl = New Excel.Application
' Set excl = CreateObject(Excel.Application)
excl.Visible = True
' Set excl = Nothing
End Sub
-
Nov 4th, 2009, 04:34 AM
#4
Re: Opening Excel when click at BtPrint_click()
i need to know step by step.
That is the reason I pointed you that link. Did you even go through it?
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Nov 4th, 2009, 04:56 AM
#5
Thread Starter
Frenzied Member
Re: Opening Excel when click at BtPrint_click()
Right know excel Is comming .when i click at the btprint_click().additional i
want to write some text at the particular cell.here in the attachment i just
changed the color to orange.i simple want when user click on the print button
excel report should come along with the fixed text .Kindly let me know the idea.
Code:
Private Sub btPrint_Click()
Dim excl As Excel.Application
Dim wBook As Excel.Workbook
Set excl = New Excel.Application
' Set excl = CreateObject(Excel.Application)
Set wBook = excl.Workbooks.Add
excl.Visible = True
' Set excl = Nothing
End Sub
Simple tell how should i print some text at the particular rows of the excel Sheet.
Last edited by firoz.raj; May 30th, 2011 at 02:10 PM.
-
Nov 4th, 2009, 07:15 AM
#6
Re: Opening Excel when click at BtPrint_click()
vb Code:
wBook.Sheets("Sheet1").Range("A1").Value = "firoz.raj"
-
Nov 4th, 2009, 07:24 AM
#7
Thread Starter
Frenzied Member
Re: Opening Excel when click at BtPrint_click()
can you tell me .How should i change the font of the particular Cell value.
Suppose here i want Company Name should Come in Bold Format.Kindly let
me know the Idea.Any help would be highly appreciated.
Code:
Private Sub btPrint_Click()
Dim excl As Excel.Application
Dim wBook As Excel.Workbook
Dim ExlSheet As Excel.Worksheet
Dim m_SCompanyName As String
m_SCompanyName = "AL ARABI FACTORY FOR STEEL WORKS "
Set excl = New Excel.Application
' Set excl = CreateObject(Excel.Application)
Set wBook = excl.Workbooks.Add
Set ExlSheet = wBook.Worksheets(1)
excl.Visible = True
ExlSheet.Cells(2, 1).Value = m_SCompanyName
ExlSheet.Cells(3, 1).Value = "P.O. BOX 14044 DAMMAM 31424 "
ExlSheet.Cells(4, 1).Value = "KINGDOM OF SAUDI ARABIA "
ExlSheet.Cells(5, 1).Value = "PHONE : (+9663) 812-3070 "
ExlSheet.Cells(6, 1).Value = "FAX : (+9663) 812-3339 "
Set excl = Nothing
End Sub
-
Nov 4th, 2009, 07:29 AM
#8
Re: Opening Excel when click at BtPrint_click()
vb Code:
ExlSheet.Range("A1:A2").Font.Bold = True
-
Nov 4th, 2009, 07:38 AM
#9
Re: Opening Excel when click at BtPrint_click()
I see a good tutorial going to waste... 
Code:
Private Sub btPrint_Click()
Dim Excl As Excel.Application, wBook As Excel.Workbook
Dim ExlSheet As Excel.Worksheet, m_SCompanyName As String
m_SCompanyName = "AL ARABI FACTORY FOR STEEL WORKS "
Set Excl = New Excel.Application
Set wBook = Excl.Workbooks.Add
Set ExlSheet = wBook.Worksheets(1)
Excl.Visible = True
ExlSheet.Cells(2, 1).Value = m_SCompanyName
'~~> To bold the cell
ExlSheet.Cells(2, 1).Font.Bold = True
ExlSheet.Cells(3, 1).Value = "P.O. BOX 14044 DAMMAM 31424 "
ExlSheet.Cells(4, 1).Value = "KINGDOM OF SAUDI ARABIA "
ExlSheet.Cells(5, 1).Value = "PHONE : (+9663) 812-3070 "
ExlSheet.Cells(6, 1).Value = "FAX : (+9663) 812-3339 "
'~~> Save and Close
wBook.SaveAs "C:\My File.xls"
wBook.Close SaveChanges:=False
'~~> You are still using the below....
'Set Excl = Nothing
'~~> You need to save the excel sheet if you need to retain the formatting
'~~> I have added the code above. just change the path as required
'~~> Clean up
Set ExlSheet = Nothing
Set wBook = Nothing
Excl.Quit
Set Excl = Nothing
End Sub
Edit: Hack beat me to it...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Nov 4th, 2009, 07:38 AM
#10
Thread Starter
Frenzied Member
Re: Opening Excel when click at BtPrint_click()
Can you tell me .How should i place Company Logo means Picture (Gif/Jpeg Picture)in Some of the particular Cell.Kindly let me know the idea.Any help would be highly appreciated.here is the following Code.
Code:
Private Sub btPrint_Click()
Dim excl As Excel.Application
Dim wBook As Excel.Workbook
Dim ExlSheet As Excel.Worksheet
Dim m_SCompanyName As String
m_SCompanyName = "AL ARABI FACTORY FOR STEEL WORKS "
Set excl = New Excel.Application
' Set excl = CreateObject(Excel.Application)
Set wBook = excl.Workbooks.Add
Set ExlSheet = wBook.Worksheets(1)
excl.Visible = True
ExlSheet.Cells(2, 1).Value = m_SCompanyName
ExlSheet.Cells(3, 1).Value = "P.O. BOX 14044 DAMMAM 31424 "
ExlSheet.Cells(4, 1).Value = "KINGDOM OF SAUDI ARABIA "
ExlSheet.Cells(5, 1).Value = "PHONE : (+9663) 812-3070 "
ExlSheet.Cells(6, 1).Value = "FAX : (+9663) 812-3339 "
ExlSheet.Range("A1:A2").Font.Bold = True
Set excl = Nothing
End Sub
-
Nov 4th, 2009, 07:41 AM
#11
Re: Opening Excel when click at BtPrint_click()
Firoz you just copied what Hack gave you...
You need to understand how the code works...
Do you know how to record a macro in Excel?
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Nov 4th, 2009, 07:58 AM
#12
Thread Starter
Frenzied Member
Re: Opening Excel when click at BtPrint_click()
Do you know how to record a macro in Excel? i don't Know myfriend Kindly
let me know.I Want To generate Excel Purchase Order Automatically.
Kindly find the attachment also.and let me know the idea.So that when
user will click on the print Button Automatic Purchase order will be created
in excel.
Code:
Private Sub btPrint_Click()
Dim excl As Excel.Application
Dim wBook As Excel.Workbook
Dim ExlSheet As Excel.Worksheet
Dim m_SCompanyName As String
m_SCompanyName = "AL ARABI FACTORY FOR STEEL WORKS "
Set excl = New Excel.Application
' Set excl = CreateObject(Excel.Application)
Set wBook = excl.Workbooks.Add
Set ExlSheet = wBook.Worksheets(1)
excl.Visible = True
ExlSheet.Cells(2, 1).Value = m_SCompanyName
ExlSheet.Cells(3, 1).Value = "P.O. BOX 14044 DAMMAM 31424 "
ExlSheet.Cells(4, 1).Value = "KINGDOM OF SAUDI ARABIA "
ExlSheet.Cells(5, 1).Value = "PHONE : (+9663) 812-3070 "
ExlSheet.Cells(6, 1).Value = "FAX : (+9663) 812-3339 "
ExlSheet.Range("A1:A2").Font.Bold = True
Set excl = Nothing
End Sub
Last edited by firoz.raj; May 30th, 2011 at 02:10 PM.
-
Nov 4th, 2009, 10:25 AM
#13
Re: Opening Excel when click at BtPrint_click()
Do you know how to record a macro in Excel? i don't Know myfriend Kindly
let me know.
http://www.vbforums.com/showthread.php?t=402032
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Nov 5th, 2009, 03:31 AM
#14
Thread Starter
Frenzied Member
Re: Opening Excel when click at BtPrint_click()
Can you tell me .How should i insert any picture file .in a excelSheet .Kindly
let me know the idea.Any help would be highly appreciated.
Code:
Private Sub btPrint_Click()
Dim excl As Excel.Application
Dim wBook As Excel.Workbook
Dim ExlSheet As Excel.Worksheet
Dim m_SCompanyName As String
m_SCompanyName = "AL ARABI FACTORY FOR STEEL WORKS "
Set excl = New Excel.Application
' Set excl = CreateObject(Excel.Application)
Set wBook = excl.Workbooks.Add
Set ExlSheet = wBook.Worksheets(1)
excl.Visible = True
ExlSheet.Cells(2, 1).Value = m_SCompanyName
ExlSheet.Cells(3, 1).Value = "P.O. BOX 14044 DAMMAM 31424 "
ExlSheet.Cells(4, 1).Value = "KINGDOM OF SAUDI ARABIA "
ExlSheet.Cells(5, 1).Value = "PHONE : (+9663) 812-3070 "
ExlSheet.Cells(6, 1).Value = "FAX : (+9663) 812-3339 "
ExlSheet.Range("A1:A2").Font.Bold = True
ExlSheet.Range("A1:A2").Font.Italic = True
ExlSheet.Range("A1:A5").Font.Underline = True
Set ExlSheet = Nothing
Set wBook = Nothing
Set excl = Nothing
End Sub
-
Nov 5th, 2009, 06:49 AM
#15
Re: Opening Excel when click at BtPrint_click()
Firoz, I believe that you don't want to learn or you are simply ignoring what others have to say...
I am sorry I won't be able to help you anymore...
If you don't want to learn and want someone to make this project for you then I suggest that you request a moderator to move this thread to "Project Requests" where someone can actually code the entire thing for you 
Good Luck...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Nov 6th, 2009, 11:20 PM
#16
Thread Starter
Frenzied Member
Re: Opening Excel when click at BtPrint_click()
What i am Ignoring My friend .Kindly let me know the idea.I simply want to
insert picture in a excel sheet using VB Code.Kindly let me know the Idea.
-
Nov 7th, 2009, 10:55 AM
#17
Re: Opening Excel when click at BtPrint_click()
Posts #13 and #2 contain all of the info you need to do almost anything with Excel from VB - inserting a picture is definitely among them.
Rather than posting things like "Kindly let me know the Idea.", you should (like most people) try to work it out yourself using the information that you have already got (in this case, Posts #13 and #2).
If you can't get it completely working, show us the code you have come up with for it (not the code for other things), and ask us for specific help to fix the problems with that code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|