|
This is so trivial, it's hard to know where to start. You grab the id of the item selected in the first column and use it to select the data you need to show in the second column. I don't see how you can mess that up, you're going to need to post some code, etc, so we can try to work out what you're screwing up.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
I have placed my Code below. Everything works fine except that the Excel application is running at the backgroung even after quitting the Excel using code also setting the Excel object to Nothing. But the Excel application terminates on closing the application.
When I click the button for the first time, the excel application appears in the task manager, but is not closing. But when I click the button for the second time a second Excel application instance appears in the task manager, but it closes immediately when I set the Excel object to "Nothing".
Anybody, pls suggest me how to close the excel instance which is created for the first time.
Private Sub ExportExcel_Click()
Dim objExcel As Excel.Application
Dim objWorkbook As Excel.Workbook
Dim objwksSheet As Excel.Worksheet
Dim Msg, style, Title, Response
style = vbYesNoCancel + vbQuestion + vbDefaultButton2 ' Define buttons.
Msg = "Before Exporting the Tags to Excel, all the unsaved Excel Files must be closed. Are you sure you want to Continue?"
Title = "PV Trend" ' Define title.
Response = MsgBox(Msg, style, Title)
If Response = vbNo Or Response = vbCancel Then ' User chose No.
Exit Sub
End If
Dim i As Long
Dim n As Long
Dim gridChart As ChartObject
Dim tagdataChart As Chart
Dim curentChart As Object
If SelTagsCnt <= 0 Then
MsgBox "No Tags are there to export"
Exit Sub
End If
'***************************************************************
' create new hidden instance of Excel and open its workbooks collection
If DebugMode = True Then
xlsfilename = "c:\testExcel.xls"
Else
xlsfilename = glbSysPath & "esim\Model\" & ModelName & _
"\Instructor\PVTREND" & ModelName & ".xls"
End If
' Set objExcel = New Excel.Application
' objExcel.Workbooks.Open xlsfilename
' objExcel.Worksheets("Sheet1").Activate
' objExcel.DisplayAlerts = False
' With objExcel
' .ActiveWorkbook.Save FileName:= _
' xlsfilename, _
' FileFormat:=xlNormal, Password:="", _
' WriteResPassword:="", ReadOnlyRecommended:=False, _
' CreateBackup:=False
'
' .ActiveWindow.Close
' End With
'*******************************************************************
On Error Resume Next
'Call EmpMSFgrid_load
'Set objExcel = GetObject(, "Excel.Application")
Set objExcel = New Excel.Application
' If Err.Number Then
' Err.Clear
' Set objExcel = CreateObject("Excel.Application")
' If Err.Number Then
' MsgBox "Unable to open Excel Application."
' End If
' End If
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Add
objExcel.Worksheets("sheet1").Activate
xlAPP.Worksheets("Sheet1").Range (strRangeXVal)
' Merging the First 3 Rows
With objWorkbook.Sheets("Sheet1")
For i = 1 To 3
.Range(.Cells(i, 1), .Cells(i, 50)).Select
Selection.Merge
Next i
End With
' Add Heading "PROSIMULATOR HISTORICAL PV TREND PLOT" in the First Row of the Excel File
objWorkbook.ActiveSheet.Cells(1, 1).Font.Bold = True
objWorkbook.ActiveSheet.Cells(1, 1).Font.Size = 18
objWorkbook.ActiveSheet.Cells(1, 1).Font.Color = RGB(0, 0, 255)
objWorkbook.ActiveSheet.Cells(1, 1).Value = " PROSIMULATOR HISTORICAL PV TREND PLOT"
objWorkbook.ActiveSheet.Cells(1, 1).Interior.Color = RGB(255, 128, 0) 'RGB(185, 185, 185)
' Format 2nd Row
objWorkbook.ActiveSheet.Cells(2, 1).Font.Bold = True
objWorkbook.ActiveSheet.Cells(2, 1).Font.Size = 11
objWorkbook.ActiveSheet.Cells(2, 1).Font.Color = RGB(41, 11, 164)
objWorkbook.ActiveSheet.Cells(2, 1).Value = "Model Name:" & ModelName
'objWorkbook.ActiveSheet.Cells(2, 1).Interior.Color = RGB(137, 200, 237)
objWorkbook.SaveCopyAs xlsfilename
' .ActiveWorkbook.SaveAs FileName:= _
' xlsfilename
objWorkbook.Close savechanges:=False
objWorkbook.Close
'Set objWorkbook = Nothing
objExcel.Visible = False
objExcel.ActiveWindow.Close
objExcel.Quit
objExcel.Application.Quit
' End With
Dim sTitle As String
Dim iHwnd As Integer
Dim ihTask As Integer
Dim iReturn As Integer
sTitle = "EXCEL"
iHwnd = FindWindow(0&, sTitle)
iReturn = PostMessage(objExcel.hWnd, WM_QUIT, 0, 0)
Set objWorkbook = Nothing
Set objExcel = Nothing
Set curentChart = Nothing
Set tagdataChart = Nothing
Set gridChart = Nothing
End Sub
|
|
|
|
|
Excel won't quit because your code still has references to object you were using in Excel. You have to explicitly set EVERY object you create in the Excel object model to Nothing, THEN call Quit, otherwise, you'll get the behavior you're seeing.
|
|
|
|
|
i have installed Visual Studio 2005.net and a writing a student management system,however, i need to create a help file,but i have got no clue....where do i begin to create one..
|
|
|
|
|
You can find a pretty tutorial here[^].
|
|
|
|
|
How to make my application shareware
|
|
|
|
|
Give it away
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
|
Hi all,
I'm currently working on an application that opens media files with respect to their file extensions. Images are opened with Microsoft image viewer, video is opened with VLC and mp3 is supposed to be played with windows media player/VLC. So far opening images works fine but when I try to open video or music files i get the error that the opened application is unable to play the file.I'm positive that It has something to do with the spaces on the file location e.g. c:\Program Files\Windows Media Player\something.mp3. Question is how do I make it that the location doesn't incur any spaces or is there another way to open the files in their respective application aside from what I've been doing. I'm using vb6 by the way. Below are the codes I use for my task:
Images
Shell "rundll32.exe C:\WINDOWS\System32\shimgvw.dll,ImageView_Fullscreen " & txtscreenshot.Text & "", vbMaximizedFocus
Video
Shell ("C:\Program Files\VideoLAN\VLC\vlc.exe " & txtscreenshot.Text & ""), vbNormalFocus
Music
Shell "C:\Program Files\Windows Media Player\wmplayer.exe " & txtscreenshot.Text & "", vbNormalFocus
Many thanks for all your replies!
|
|
|
|
|
Shell "C:\Program Files\Windows Media Player\wmplayer.exe '" & txtscreenshot.Text & "'", vbNormalFocus
Notice the extra quotes around "txtscreenshot.Text"
tatchung wrote: I'm using vb6
..why? VB.NET is a free download, check out Visual Basic.NET Express
I are troll
|
|
|
|
|
Hi! Thanks for the reply
Eddy Vluggen wrote: Notice the extra quotes around "txtscreenshot.Text" Smile
Yeah I've tried removing that quote but it still doesn't open. So in static "txtscreenshot.Text" generates path names like "C:\Documents and Settings\Computer1\Desktop\New\something.mp3". Shell command recognizes "C:\Documents" as 1 file "and" as another and so on. How can I make it recognize the path name as it is?
Eddy Vluggen wrote: ..why? VB.NET is a free download, check out Visual Basic.NET Express Smile
I know...that's a great deal of my problem
Aim small, miss small
|
|
|
|
|
tatchung wrote: I know...that's a great deal of my problem
What does this mean ? VB6 was always crap, and it's been unsupported for a long time. In VB.NET, you drag a WMP control onto your form and tell it what to play, easy.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Couldn't agree more...i meant using vb6 has been a burden for me. Unfortunately this was a requirement...client haven't, couldn't, wouldn't install a .NET framework for reasons they "wouldn't" disclose. Lotsa "'s"s in there
Aim small, miss small
|
|
|
|
|
Perhaps this one?
Shell "C:\Program Files\Windows Media Player\wmplayer.exe " & Chr(34) & txtscreenshot.Text & Chr34, vbNormalFocus
The above code will put quotation-marks inside the command. That way Windows knows that the path doesn't end after the first space that it sees.
Enjoy[^]
I are troll
|
|
|
|
|
|
In my project while images are loading in to application if i try to close application its not closing, After the completion of loading only it is closing.
Please help me what is the problem. How to close the Application.
|
|
|
|
|
All your images are being loaded by code on the UI thread. It's busy doing that, so there's no way for the UI thread to respond to the Close messages it's getting. You have to move your image loading code to another thread so the UI thread can get the messages to close.
|
|
|
|
|
Hi,
as Dave said, use another thread to load the images.
Don't forget to make it a background thread, i.e. one that does not prevent the app from closing
while it, the thread, still has some work left.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
When I Working on this code it will work properly with minimize status.
Shell("cmd", AppWinStyle.MinimizedFocus)
SendKeys.Send("-")
SendKeys.Send("C:{ENTER}")
SendKeys.Send("DIR{ENTER}")
SendKeys.Send("CD WINDOWS{ENTER}")
But same code with small change in Open the Command Prompt(Hide status).
It open the maximum Process. I checked in Task manager
The Code as Follows.
Shell("cmd", AppWinStyle.Hide)
SendKeys.Send("-")
SendKeys.Send("C:{ENTER}")
SendKeys.Send("DIR{ENTER}")
SendKeys.Send("CD WINDOWS{ENTER}")
plzzz help me.
|
|
|
|
|
This isn't going to work. SendKeys sends keystrokes to the window that has the input focus. Since you launched the CMD prompt hidden, it can't possibly have the input focus. Your app retains the input focus, so you just sent all those keystrokes to your own app, not the CMD prompt you launched.
I have no idea what you're trying to accomplish with this, so I can't tell you what the best solution would be...
|
|
|
|
|
I want take a backup from PostgreSQL from vb.net so I know only one way is command prompt.
When user click on Backup I want take backup. but user not aware of open command prompt.
Sorry My English is poor plzz understand i help me.
|
|
|
|
|
You don't use a command prompt to do this. Use the Process class[^] to launch the same command you would type at that prompt to do it without the prompt.
|
|
|
|
|
I have a DataGridView whos datasource is a bindingSource. I wish to filter the DataGridView via a comboBox, with a button to instigate the whole thing. So I have:
Private sub selectionButton_Click(ByVal sender as system object, byVal e as system.eventargs) handles selectionButton.click
transactionBindingSource.filter = String.format("TranType = '{0}'", itemSelectionComboBox.text)
End Sub
But although tracing the code shows that the filter is correctly selected, my DataGridView does not reflect the filtering selected.
What am I doing wrong please?
|
|
|
|
|
You need to rebind the data source
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Well, I originally thought that too Bob, and tried adding:
transactionDataGridView.DataSource = nothing<br />
transactionDataGridView.DataSource = transactionBindingSource
without success
|
|
|
|
|