on 06-10-2011 6:47 AM
Hi Experts,
I want to Browse a txt file or xls file & fill a EditText with the File path..
Simply I want to attach a file in my own created Form in SAP..
How it can be done?
Thanks,
Nabanita Ghosh
Hi,
This is in VB.Net
Call function as
Me.BrowseFileDialog(objForm)
-
Sub ShowFolderBrowser()
Dim MyTest As New OpenFileDialog
Dim MyProcs() As Process
MyProcs = Process.GetProcessesByName("SAP Business One")
If MyProcs.Length <> 0 Then
For i As Integer = 0 To MyProcs.Length - 1
Dim MyWindow As New WindowWrapper(MyProcs(i).MainWindowHandle)
MyTest.Filter = "Excel files (*.xls)|*.xls|Document files (*.doc)|*.doc"
If MyTest.ShowDialog(MyWindow) = DialogResult.OK Then
If objForm.Mode = SAPbouiCOM.BoFormMode.fm_OK_MODE Or objForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE Then
objForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE
End If
'MessageBox.Show(MyTest.FileName)
importpath = MyTest.FileName
If importpath <> Nothing Then
Try
Dim oDt As SAPbouiCOM.DataTable
oDt = Nothing
oDt = ReadXlDataFile(importpath)
Catch ex As Exception
MsgBox(ex.Message)
objForm.Freeze(False)
End Try
End If
System.Windows.Forms.Application.ExitThread()
Else
System.Windows.Forms.Application.ExitThread()
End If
Next
Else
Console.WriteLine("No SBO instances found.")
End If
End Sub
-
Sub BrowseFileDialog(ByVal objForm As SAPbouiCOM.Form)
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
objMain.objApplication.StatusBar.SetText(ex.Message)
End Try
End Sub
End Class
Now if you want it in C#.. that you have to do yourself..
regards:
Sandy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
110 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
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.