|
Hi Paritosh,
I thought that this was the problem but I haven't figured out how to do it. If I use a "close" event in the sub that shows the "Excel" workbook, the workbook flashes on the screen and back off before you get to look at it. I tried to put it in my main form "activate" sub and that didn't work either. I need this to happen automaticly as the user closes the "Excel" window so they can just click on another part of the picture.
Could you give me an idea of what the code would look like and what sub to put it in? Like I said, I'm "self-taught" in "VB" so my teacher isn't the sharpest tool in the shed.
Thanks again, Garner
|
|
|
|
|
Hello, I have the following code:
<br />
excelApp = CreateObject("Excel.Application")<br />
excelWorkbook = excelApp.Workbooks.Open(Filename:=FILE, UpdateLinks:=False, ReadOnly:=False)<br />
<br />
With excelWorkbook.ActiveSheet<br />
<br />
For i As Integer = 0 To 5<br />
.Cells((i + 2), 1) = i<br />
.Cells((i + 2), 2) = i+1<br />
Next i<br />
<br />
End With<br />
<br />
excelWorkbook.Save()<br />
I want to be able to change the font/color of the text displayed in each cell, however I am not sure how to do so. Is there a way to do this? Please help.
Mike - I love to program!
|
|
|
|
|
hi,
Select the cell
cells(1,1).Select
selection.font.bold=true
Selection.Font.ColorIndex = 50
50 is the for green
bye.
Paritosh
|
|
|
|
|
That didn't work. I am using VB.Net and it does not recognize selection. I tried using the Excel.Application selection and applying your code, as well as Selection.Font.FontStyle = "Bold", but that did not work either. Is there something that I am missing?
I love to program!
|
|
|
|
|
try out this
cells(1,1).activate
activecell.font.color=10
activecell.font.bold=true
Paritosh
|
|
|
|
|
the code as you typed it there wouldn't compile, so I tried this:
.Cells(1,1).Activate()
excelApp.ActiveCell.Font.Bold = True
excelApp.ActiveCell.Color = 10
The code compiled and the program ran perfectly, however the font was not bold nor was the color changed when I opened the excel file. Does the fact that I'm using VB.Net change anything?
I love to program!
|
|
|
|
|
i am using VB 6.0.
so for vb .net some modification required..which you can do (I yhink)
anyway try this
dim wb as workbook
dim ws as worksheet
set wb=excelApp.workbooks.open("file name")
set ws=wb.sheets(1)
ws.cells(1,1).activate
ws.activecell.font.bold=true
ws.activecell.font.colorindex=10
bye.
Paritosh
|
|
|
|
|
I tried the code you gave and ActiveCell isn't a member of the worksheet class. I have worked with VBA but not enough to know how to convert between VBA and VB.Net. Thanks for all of your help though.
I love to program!
|
|
|
|
|
try worksheet.range("A3").font.bold=true
Paritosh
|
|
|
|
|
Thanks for all the help, I was able to finally get it thanks to you.
I love to program!
|
|
|
|
|
How do I create a datagrid in Visual studio,
populate it with 3 database table fields
and display it on a web page
|
|
|
|
|
Hi, i have been experimenting with the clipboard in vb.net and have been able to copy to/paste from the clipboard as following:
If Clipboard.GetDataObject.GetDataPresent(DataFormats.Bitmap) Then
'setting clipboard data to picturebox
pbxMovie.Image = Clipboard.GetDataObject().GetData(DataFormats.Bitmap)
End If
Now, this works fine within applications. for example i can copy to/paste from word and also in my applications. but when i try to copy something form my desktop or harddisk, it doesnt work.
Also when i try to paste on my desktop/harddisk, it simply isnt in the clipboard (no 'paste' option in the context menu)
Anyone got any ideas?
|
|
|
|
|
If you're copying/pasting stuff from the Desktop or a Drive, you're not working with an image, you're working with a filepath. Copy something from the drive, then check the types of what is stored on on the Clipboard.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi All!
Some one plz tell me that how can i call submit event of a form from the Document captured by AxWebBrowser...i m already handeling other controls's events like..
WB.Document.links.Item(lst.SelectedIndex).Click()
but unable to call submit or any othert event of particular form say 'form1'
Regard,
Sufyan
|
|
|
|
|
You may use a link with href something like this one:
< a href = "Form1.submit()" > [Your text] < / a >
I dont know whether it is a good solution b ut I got the same problem like you before.
Hope it helps,
|
|
|
|
|
Hello guys..
I want to create a setup file for my application thats is done vs 2005..
how do i compile the crystal report information to the setup file
cause now when i run the report from my application after setup the is error
itried to copy manually the dll into the directory.. still cannot
diff error come out saying that.. the file to something i n registery..
now i'm a hurry so pls help...
thanks
|
|
|
|
|
To deploy your application, you need to create a setup project and add the necessary merge modules to your application before you build your solution.
Open your Windows application.
In the Solution Explorer, right-click your Windows application solution, point to Add then click New Project.
In the Add New Project dialog box, select Setup and Deployment Projects in the Project Types pane and select Setup Project in the Templates pane. Click OK.
In the Solution Explorer, right-click the Setup Project, point to Add then click Project Output.
In the Add Project Output Group, select Primary output and click OK. Any dependencies, such as the Managed.msm, are added automatically.
In the Solution Explorer, right-click the Setup Project, point to Add then click Merge Module.
In the Add Modules dialog box, select the following merge modules to add to your Setup project and click Open:
Database_Access.msm
Database_Access_enu.msm
regwiz.msm
For a description of these merge modules see Crystal Reports Merge Modules (ms-help://MS.VSCC/MS.MSDNQTR.2003JAN.1033/crystlmn/html/crconcrystalreportsmergemodules.htm). Note If you deploy a Windows application that uses an ADO .NET dataset, you also need to include the VC_CRT and VC_STL merge modules.
In the Solution Explorer, right-click the regwiz.msm file and choose Properties.
In the Properties window, expand MergeModuleProperties and enter a valid license key in the License Key properties box. Note Providing the license key is a mandatory step whenever you deploy a Crystal Reports for Visual Studio .NET application. A license key will be given to you once you have registered Crystal Reports for Visual Studio .NET. You can find the license key in the About dialog box. From the Help menu, choose About Microsoft Development Environment. The keycode is listed in the Installed Products field.
From the Build menu, choose Build Solution to build your application. When deploying to a client or server computer.
karim ben romdhane Tunisia
As I grow up I pay less attention to what men say, I just watch what they do.
|
|
|
|
|
thanks for the reply
it works now
|
|
|
|
|
hello,
The code shown below is for excel sheet generation but when i execute this i am getting an error as access is denied .plz go though the code and if any mistake plz correct it ....
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
da1.MissingSchemaAction = MissingSchemaAction.AddWithKey
CMD.Connection = con
con.Open()
CMD.CommandType = CommandType.StoredProcedure
CMD.CommandText = "ACE_CONTROLTOWER"
Dim cellid As New SqlParameter
Dim fromDATE As New SqlParameter
'Dim tomonth As New SqlParameter
'Dim fromyear As New SqlParameter
Dim toDATE As New SqlParameter
cellid.ParameterName = "@CELLID"
cellid.SqlDbType = SqlDbType.VarChar
cellid.Value = TextBox1.Text
cellid.Direction = ParameterDirection.Input
CMD.Parameters.Add(cellid)
fromDATE.ParameterName = "@fromDATE"
fromDATE.SqlDbType = SqlDbType.DateTime
fromDATE.Value = TextBox2.Text
fromDATE.Direction = ParameterDirection.Input
CMD.Parameters.Add(fromDATE)
toDATE.ParameterName = "@toDATE"
toDATE.SqlDbType = SqlDbType.DateTime
toDATE.Value = TextBox5.Text
toDATE.Direction = ParameterDirection.Input
CMD.Parameters.Add(toDATE)
Dim dr As SqlDataReader
dr = CMD.ExecuteReader()
DataGrid2.DataSource = dr
DataGrid2.DataBind()
dr.Close() 'closing data reader
CMD.Dispose()
con.Close()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
bln = CreateExcelWorkbook("example")
'= Server.MapPath(".") + "\PWReports\"
filePath = "c:\"
filename = "example"
filePath = filePath & filename & ".xls"
Dim MyFileStream As FileStream = New FileStream(filePath, FileMode.Open)
Dim FileSize As Long
FileSize = MyFileStream.Length
Dim Buffer(FileSize) As Byte
MyFileStream.Read(Buffer, 0, MyFileStream.Length)
MyFileStream.Close()
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition", "attachment; filename=" & filename & " .xls")
Response.BinaryWrite(Buffer)
End Sub
Public Function CreateExcelWorkbook(ByVal strFileName As String) As Boolean
Dim oXL As Excel.Application
Dim oWB As Excel._Workbook
Dim oSheet, oSheet1, oSheet2 As Excel._Worksheet
Dim oRng As Excel.Range
filePath = "c:\"
filename = "example"
'Dim strCurrentDir As String
'strCurrentDir = Server.MapPath(".") + "\PWReports\"
Try
GC.Collect() '// clean up any other excel guys hangin' around...
oXL = New Excel.Application
oXL.Visible = False
'//Get a new workbook.
oWB = CType(oXL.Workbooks.Add("WorkBook"), Excel._Workbook)
oSheet = CType(oWB.Sheets("sheet1"), Excel._Worksheet)
oSheet.Name = "controltower"
oSheet.Range("A1", "O1").Font.Name = "Arial"
oSheet.Range("A1", "O1").Font.Size = 13.5
oSheet.Range("A1", "O1").Font.Color = RGB(255, 0, 0)
oSheet.Range(oSheet.Cells(1, 1), oSheet.Cells(1, 2)).Merge()
oSheet.Range(oSheet.Cells(1, 1), oSheet.Cells(1, 2)).Interior.Color = RGB(255, 255, 153)
oSheet.Range(oSheet.Cells(1, 1), oSheet.Cells(1, 2)).Value = "Infotech LCS Report : "
oSheet.Range(oSheet.Cells(1, 1), oSheet.Cells(1, 2)).Borders.ColorIndex = RGB(0, 0, 0)
oSheet.Range(oSheet.Cells(1, 1), oSheet.Cells(1, 2)).Font.Color = RGB(0, 0, 255)
oSheet.Range(oSheet.Cells(1, 1), oSheet.Cells(1, 2)).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter
oSheet.Range("A1", "O1").Font.Bold = True
oSheet.Range("A1", "O1").VerticalAlignment = Excel.XlVAlign.xlVAlignCenter
oXL.WindowState = Excel.XlWindowState.xlMinimized
oXL.Visible = True
oXL.UserControl = True
oSheet.Activate()
oXL.ActiveWindow.Zoom = 73
oSheet.Range("A4", "O4").Select()
oXL.ActiveWindow.FreezePanes = True
strfile = filename & ".xls"
Call RemoveFiles(filepath, strfile)
oWB.SaveAs(filePath + strfile, Excel.XlFileFormat.xlWorkbookNormal, Nothing, Nothing, False, False, Excel.XlSaveAsAccessMode.xlNoChange, False, True, Nothing, Nothing)
'// Need all following code to clean up and extingush all references!!!
oWB.Close(Nothing, Nothing, Nothing)
oXL.Workbooks.Close()
oXL.Quit()
Call KillProcess("EXCEL")
'System.Runtime.InteropServices.Marshal.ReleaseComObject(oRng)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oXL)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oSheet)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oSheet1)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oSheet2)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oWB)
oSheet = Nothing
oSheet1 = Nothing
oSheet2 = Nothing
oWB = Nothing
oXL = Nothing
GC.Collect() '// force final cleanup!
'Dim strMachineName As String = Request.ServerVariables("SERVER_NAME")
'errLabel.Text = "Download Report"
Return True
Catch theException As Exception
Response.Write(Err.Description)
Response.End()
Dim errorMessage As String
errorMessage = "Error: "
errorMessage = String.Concat(errorMessage, theException.Message)
errorMessage = String.Concat(errorMessage, " Line: ")
errorMessage = String.Concat(errorMessage, theException.Source)
Call KillProcess("EXCEL")
'System.Runtime.InteropServices.Marshal.ReleaseComObject(oRng)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oXL)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oSheet)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oSheet1)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oSheet2)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oWB)
oSheet = Nothing
oWB = Nothing
oXL = Nothing
GC.Collect() '// force final cleanup!
Return False
End Try
End Function
'Removing Excel Files
Private Sub RemoveFiles(ByVal strPath As String, ByVal fileName As String)
Dim di As System.IO.DirectoryInfo = New DirectoryInfo(strPath)
Dim fiArr() As FileInfo = di.GetFiles()
Dim fri As FileInfo
For Each fri In fiArr
If (fri.Name.ToString() = fileName) Then
fri.Delete()
End If
Next
End Sub
'Killing The Process
Private Sub KillProcess(ByVal strPrc As String)
Dim myproc As System.Diagnostics.Process = New System.Diagnostics.Process
Dim i As Integer
''Get all instances of proc that are open, attempt to close them.
Try
' i = Process.GetProcessesByName(strPrc).Length
For Each myproc In Process.GetProcessesByName(strPrc)
If Not (myproc.CloseMainWindow()) Then
''If closing is not successful or no desktop window handle, then force termination.
myproc.Kill()
Exit For
End If
Next myproc
Catch
Response.Write(Err.Description)
End Try
End Sub
End Class
thanks & regards
nagalakshmi
|
|
|
|
|
hi!
as far as i think ur connection object is faulty create cnnection object with appropriate parameters.. like if u r using sqlconnection it would be
dim constr as string="server=[servername];user Id=[username/sa];password=[pwd/""]initial catalog=[database name];"
dim con as new sqlconnecton(constr)
better if u would send connecton code as well..
GoodLuck!!
Sufyan
|
|
|
|
|
Hi all
I have a confusion that weather user controls
can be added as a column of datagrid through datagrid TextBox Column
AS i made a user control but that is not added with its full functionalities in the datagrid.
means many properties are not working when i embed a user control inside datagrid Column.
Thanks in advanece
Hema Chaudhry
|
|
|
|
|
Hi all,
I want to add the ListView Control in the Combobox control of vb.net
as I want to show the multiple columns in the combo box
SO I want to achieve this functionality with list view
AS the user Click on down arrow of Combo Box
that will show the listview
populateListView()<br />
<br />
Me.ComboBox1.Controls.Add(listview1)
But I am Not Successful
Its very urgent for me
I will highly appreciate Any help
Thanks in advance
Hema Chaudhry
|
|
|
|
|
No need 2 create that its already there..
follow link
http://www.codeproject.com/vb/net/MultiColumnFlatCombo.asp
enjoy!!
Sufyan,
|
|
|
|
|
Thanks for reply
But I have seen these all links of multiColumnComboBox
They are not working with my datagrid
The link which u suggest has the limitation that it limits the Column Numbers (Only 4) for the MultiCOlCombo
http://www.codeproject.com/vb/net/MultiColumnFlatCombo.asp[^]
So I want to generate my own Control
So that that control can be embed with datagrid.
I think Controls can't be added with the DatagridTextBoxColumn
I m right/not????????
Hema Chaudhry
|
|
|
|
|
Hema!
i think u can add controls in data grid as i 've heared about this
and hve jsu added a lisbox in a grid it works..keep it up ..
Sufyan,
|
|
|
|
|