cancel
Showing results for 
Search instead for 
Did you mean: 

internal error at open dialog box

Former Member
0 Kudos

Hi All,

I have created an add-on, there i have given the facility for attachments. When i click on browse button open dialog box opens.

In some computers when i click on browse button, it gives internal error (-2147467259) occurred -unspecified Error.

So can any one help on this?

Regard's

Hari

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Harinaryan,

Please check if the company's Attachment folder is available in all the computers.

Example: If you define the attachment folder as C:Program FilesSAPSAP Business OneAttachemnts (local folder) and in some machines that path does not exist, you can get that error. So make sure the attachment folder is a network shared folder like

SAPSERVERB1_SHRAttachments.

Regards,

Vítor Vieira

Former Member
0 Kudos

Hi Vitor,

Hari has created an add-on and within this add-on he has used browse button to provide attachment facility in one form.

As far as attachment folder is concerned, it is not the case because he is running in the single PC environment.

BR

Samir Gandhi

Former Member
0 Kudos

Hi Samir,

Hari has created an add-on and within this add-on he has used browse button to provide attachment facility in one form.

To get attanchments in B1, you can either create you own code to call a FileBrowser dialog or you can bind a EditText to a Link type user field and you need no code... Now, which of these method Harinaryan used?! If he used the second method, the default path will be the company's attachment folder.

As far as attachment folder is concerned, it is not the case because he is running in the single PC environment.

Harinaryan said "In some computers when i click on browse button...", so he's not in a single PC enviroment...

Regards,

Vítor Vieira

Former Member
0 Kudos

hi Vitor

i found the same problem.

i just observe that in which computer visual studio is not installed only that computer will give the internal error.

in that computers framework 2.0 is available but not full visual studio.

so is there any references to add in that computers??

here my code for activeEx

oItem = oForm.Items.Add("BrowseA", SAPbouiCOM.BoFormItemTypes.it_ACTIVE_X)

oItem.Top = 20

oItem.Left = 20

oItem.Width = 0

oItem.Height = 0

oActiveX = oItem.Specific

oActiveX.ClassID = "MSComDlg.CommonDialog"

oActiveX.ClassID = "{F9043C85-F6F2-101A-A3C9-08002B2F49FB}"

'// And here is the code to open the save dialog box

oOpenDialog = New OpenFileDialog()

oForm = SBOApp.Forms.Item("frmHazard")

oForm.Items.Item("BrowseA").Specific.Object.FileName = ""

oForm.Items.Item("BrowseA").Specific.Object.Filter = "JPG(.JPG,.JPEG)|.JPG;.JPEG|GIF(.GIF)|.GIF|Bitmap (.bmp)|.bmp"

oForm.Items.Item("BrowseA").Specific.Object.ShowOpen()

i have added this much of references

Interop.ADOMD.dll

Interop.ADOR.dll

Interop.CompSvcsAtlSupport.dll

Interop.MSComDlg.dll

Interop.SAPbobsCOM.dll

Interop.SAPbouiCOM.dll

Can u help me out plz

Former Member
0 Kudos
========

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

========

Public Sub SBO_ManageItemEvent( _
  ByVal FormUID As String, _
  ByRef pVal As SAPbouiCOM.ItemEvent, _
  ByRef BubbleEvent As Boolean _
) ' Item Event Handler
 
  Dim oForm As SAPbouiCOM.Form
  oForm = SBO_Application.Forms.Item(FormUID)
 
  Select Case pVal.EventType
 
      Case SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED
 
	  Select Case pVal.ItemUID
 
	      Case "btnBrowse"       ' Select file
		  If Not pVal.BeforeAction Then
		      Call ShowFolderBrowser(oForm)
		  End If
 
	  End Select
  End Select
 
  oForm = Nothing
 
End Sub
 
Private Sub ShowFolderBrowser(ByRef oForm As SAPbouiCOM.Form)
 
  Try
 
      ' ++++++++++++++++++++++++++++++++++++++++++++++++++
      ' I'm using default path...
      ' ++++++++++++++++++++++++++++++++++++++++++++++++++
      Dim sPath As String = SBO_Company.ExcelDocsPath
 
      oForm.Freeze(True)
 
      SBO_Application.Desktop.State = BoFormStateEnum.fs_Minimized
 
      ' ++++++++++++++++++++++++++++++++++++++++++++++++++
      ' All windows down with command ^M
      ' ++++++++++++++++++++++++++++++++++++++++++++++++++
      Const KEYEVENTF_KEYUP = &H2
      Const VK_LWIN = &H5B
      Call keybd_event(VK_LWIN, 0, 0, 0)
      Call keybd_event(77, 0, 0, 0)
      Call keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0)
 
      Dim fileName As String = ""
 
      Dim OpenFileDialog As New OpenFileDialog
      OpenFileDialog.Title = "Select Excel File"
      OpenFileDialog.Filter = "Excel files (*.xls)|*.xls"
      If Not sPath.Equals("") Then
	  OpenFileDialog.InitialDirectory = sPath
      Else
	  OpenFileDialog.InitialDirectory = Me.SBO_FormEventHDL.BdgPathLog  '"C:\"
      End If
      If OpenFileDialog.ShowDialog() = DialogResult.OK Then
	  fileName = OpenFileDialog.FileName
	  sFileXls = fileName
 
	  ' ++++++++++++++++++++++++++++++++++++++++++++++++++
	  ' Here I post getted path into my edittext field
	  ' ++++++++++++++++++++++++++++++++++++++++++++++++++
	  Dim oEdit As SAPbouiCOM.EditText
	  Dim oItem As SAPbouiCOM.Item
	  oItem = oForm.Items.Item("eFileName")
	  oEdit = oItem.Specific
	  oEdit.Value = sFileXls
 
	  oItem = Nothing
	  oEdit = Nothing
 
      End If
 
  Catch ex As Exception
    ' log exception
  Finally
      oForm.Freeze(False)
      SBO_Application.Desktop.State = BoFormStateEnum.fs_Restore
      System.GC.Collect() 'Release the handle to the table 
  End Try
 
End Sub