on 10-17-2008 8:57 AM
Hi....
I want to Select .txt File From Required Location. on click event of Button.
Please Help
Hi venkat,
use the following code on item pressed event..
Case SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED
Select Case pVal.ItemUID
Case "Btnbrowse"
Me.OpenFile()
end select
Private Sub OpenFile(ByRef BubbleEvent As Boolean)
Try
ShowFolderBrowserThread = New Threading.Thread(AddressOf ShowFolderBrowser)
If ShowFolderBrowserThread.ThreadState = ThreadState.Unstarted Then ShowFolderBrowserThread.SetApartmentState(ApartmentState.STA)
ShowFolderBrowserThread.Start()
ElseIf ShowFolderBrowserThread.ThreadState = ThreadState.Stopped Then
ShowFolderBrowserThread.Start()
ShowFolderBrowserThread.Join()
End If
Catch ex As Exception
sbo_application.MessageBox("OpenFile" & ex.Message)
End Try
Private Sub ShowFolderBrowser()
Dim MyTest As New OpenFileDialog
Dim MyProcs() As System.Diagnostics.Process
Dim filename As String
MyProcs = process.GetProcessesByName("SAP Business One")
If MyProcs.Length = 1 Then
For i As Integer = 0 To MyProcs.Length - 1
'// WindowWraper concepts are used to access open dialogue box of windows
Dim MyWindow As New WindowWrapper(MyProcs(i).MainWindowHandle)
MyTest.Filter = "Excel files (.xls)|.xls|Document files (.doc)|.doc|Presentation (.ppt)|.ppt|Adobe PDF Files (.pdf)|.pdf|Text Documents (.txt)|.txt" '|All Files (.)|."
'MyTest.InitialDirectory = "C:\Program Files\SAP\SAP Business One\Attachments"
'// Initial path for open dialogue box
'// We can change as per the requirements
MyTest.InitialDirectory = "C:\Program Files\SAP\SAP Business One\Attachments"
If MyTest.ShowDialog(MyWindow) = DialogResult.OK Then
filename = MyTest.FileName
.your validations........
.
.
Else
System.Windows.Forms.Application.ExitThread()
End If
end sub
Public Class WindowWrapper
Implements System.Windows.Forms.IWin32Window
Private _hwnd As IntPtr
Public Sub New(ByVal handle As IntPtr)
_hwnd = handle
End Sub
Public ReadOnly Property Handle() As System.IntPtr Implements System.Windows.Forms.IWin32Window.Handle
Get
Return _hwnd
End Get
End Property
End Class
to open the file you can use the follwing code on display button pressed.
Private Sub fileopen(ByVal filename As String)
'// Opening specified document with reference to the filename distributed
Try
System.Diagnostics.Process.Start(filename)
Catch ex As Exception
sbo_application.StatusBar.SetText("File Not Found in Specified Path:" & filename, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error)
End Try
End Sub
Regards,
Ganesh K
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Can anyone tellme why im loosing the thread???
Private Sub OpenFile(ByRef BubbleEvent As Boolean)
Try
Dim ShowFolderBrowserThread As New Threading.Thread(AddressOf ShowFolderBrowser)
If ShowFolderBrowserThread.ThreadState = System.Threading.ThreadState.Unstarted Then
ShowFolderBrowserThread.SetApartmentState(Threading.ApartmentState.STA)
ShowFolderBrowserThread.Start()
ElseIf ShowFolderBrowserThread.ThreadState = System.Threading.ThreadState.Stopped Then
ShowFolderBrowserThread.Start()
ShowFolderBrowserThread.Join()
End If
Catch ex As Exception
SBO_Application.MessageBox("OpenFile" & ex.Message)
End Try
End Sub
if pval.itepressed="" then
Try
ShowFolderBrowserThread = New Threading.Thread(AddressOf ShowFolderBrowser)
If ShowFolderBrowserThread.ThreadState = ThreadState.Unstarted Then
ShowFolderBrowserThread.SetApartmentState(ApartmentState.STA)
ShowFolderBrowserThread.Start()
'ShowFolderBrowserThread.Join()
ElseIf ShowFolderBrowserThread.ThreadState = ThreadState.Stopped Then
ShowFolderBrowserThread.Start()
ShowFolderBrowserThread.Join()
End If
Catch ex As Exception
ShowFolderBrowserThread.Abort()
'objMain.objApplication.StatusBar.SetText(ex.Message)
Finally
' ShowFolderBrowserThread.Abort()
End Try
end if
Rgds
Micheal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
104 | |
12 | |
11 | |
6 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.