|
.Hide() does just that, hides the form. It does NOT close it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
But I really get this problem,
actually, I think the main reason that close the application is the project start up from module.
when I create the form object and form.showdialog.
But after I hide the form, the procedure come back to the module and the project end.
How to get rid of this?
|
|
|
|
|
I don't understand what you're saying.
How about posting the code in your module that is starting this form?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi all,
I am new to this forum so please bear with me until I learn how things are done here.
I am trying to write a “VB-6” program where the user can click on a picture of a part and the program then opens an “Excel” price list for them. I used a transparent text box over the picture. You can start the program, click the picture, and an “Excel” window opens with the proper line highlighted. Then, if you close the “Excel” window and try to click on the picture again, the program balks. Part of the “Excel” window appears but it is empty. The program doesn’t crash. It just refuses to show the “Excel” sheet again.
This is the code that I used:
Dim AppExcel As Excel.Application
This sub sets the focus on the picture so the scroll bar doesn’t blink.
Private Sub Form_Activate()
p4l80e.SetFocus
End Sub
This sub tells the program to open “Excel”.
Private Sub Form_Load()
Set AppExcel = CreateObject("Excel.Application")
Workbooks.Open FileName:="D:\K and D (152598).xls"
End Sub
This sub makes “Excel” visible, finds the proper row, and highlights the entire row.
Private Sub lbl034_Click()
'On Error GoTo erh
AppExcel.Visible = True
Cells.Find(What:="34034b", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
'Highlights the entire row.
If IsEmpty(ActiveCell) Then Exit Sub
On Error Resume Next
If IsEmpty(ActiveCell.Offset(0, -1)) Then Set LeftCell = ActiveCell Else Set LeftCell = ActiveCell.End(xlToLeft)
If IsEmpty(ActiveCell.Offset(0, 1)) Then Set RightCell = ActiveCell Else Set RightCell = ActiveCell.End(xlToRight)
Range(LeftCell, RightCell).Select
Exit Sub
erh: MsgBox Error(Err)
End Sub
This is a different attempt at the above code with a different part number. It will work the first time around also. Second attempt, it also will not respond.
Private Sub lbl070_Click()
On Error GoTo erh
'Set AppExcel = CreateObject("Excel.Application")
Workbooks.Open FileName:="D:\K and D (152598).xls"
Cells.Find(What:="34070e", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
AppExcel.Visible = True
Exit Sub
erh: MsgBox Error(Err)
End Sub
The following code works fine. It just controls the scroll bar to move the picture of the parts to be selected.
Private Sub scr_Change()
On Error GoTo erh
p4l80e.Top = scr.Value
' p24L80E.Top = scr.Value + 12500
erh:
End Sub
Private Sub scr_Scroll()
Call scr_Change
p4l80e.SetFocus
End Sub
I am FAR from a pro. at this. I just taught myself from books that I bought so I might not understand a reply unless it’s kept pretty simple and straight forward.
Thanks in advance, Garner
|
|
|
|
|
hi,
just close the workbook and also quit the excel application before exiting the Sub routine.
Paritosh
|
|
|
|
|
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
|
|
|
|
|