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
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
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
Re: Opening Excel when click at BtPrint_click()
Quote:
i need to know step by step.
That is the reason I pointed you that link. Did you even go through it?
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.
Re: Opening Excel when click at BtPrint_click()
vb Code:
wBook.Sheets("Sheet1").Range("A1").Value = "firoz.raj"
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
Re: Opening Excel when click at BtPrint_click()
vb Code:
ExlSheet.Range("A1:A2").Font.Bold = True
Re: Opening Excel when click at BtPrint_click()
I see a good tutorial going to waste... http://www.vbforums.com/attachment.p...1&d=1238901874
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...
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
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?
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
Re: Opening Excel when click at BtPrint_click()
Quote:
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
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
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 :wave:
Good Luck...
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.
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.