Skip to Content
0
Former Member
Mar 14, 2006 at 09:36 PM

A Little example. Common Dialog in a SAP Business One

81 Views

Hi all,

this is a little example to use ActiveX in SAP Form. This code run in vb6.0

'**** Main Class SboClass

'**** Declarations

Private WithEvents Dlg As CommonDialog

Private WithEvents SBO As SAPbouiCOM.Application

Private Sub Class_Initialize()

' **** DoSomething

End Sub

Private Sub SBO_AppEvent(ByVal EventType As SAPbouiCOM.BoAppEventTypes)

' **** DoSomething

End Sub

Private Sub SBO_ItemEvent(ByVal FormUID As String, pVal As SAPbouiCOM.IItemEvent, BubbleEvent As Boolean)

Dim oforW As SAPbouiCOM.Form

Dim PackF As SAPbouiCOM.FormCreationParams

Dim Str As String

If pVal.InnerEvent = False Then

If pVal.Before_Action = True Then

Select Case pVal.EventType

Case et_ITEM_PRESSED:

'Button to open common dialog

If pVal.ItemUID = "ILE_001" Then

Set PackF = SBO.CreateObject(cot_FormCreationParams)

PackF.FormType = "ILE_F01"

PackF.BorderStyle = fbs_Fixed

PackF.uniqueID = "ILE_F01"

Set oforW = SBO.Forms.AddEx(PackF)

oforW.Visible = False

oforW.Width = 1

oforW.Height = 1

'Common Dialog

oforW.Items.Add "ILE_AX01", it_ACTIVE_X

oforW.Items("ILE_AX01").Left = 6

oforW.Items("ILE_AX01").Top = 10

oforW.Items("ILE_AX01").Width = 1

oforW.Items("ILE_AX01").Height = 1

oforW.Items("ILE_AX01").Specific.ClassID = "MSComDlg.CommonDialog.1"

oforW.Items("ILE_AX01").Specific.Object.DialogTitle = "Find File"

oforW.Items("ILE_AX01").Specific.Object.DefaultExt = "*.txt"

oforW.Items("ILE_AX01").Specific.Object.Filter = "Text (.txt)|.txt|All (.)|."

oforW.Items("ILE_AX01").Specific.Object.ShowOpen

Str = oforW.Items("ILE_AX01").Specific.Object.FileName

If Str = "" Then

SBO.MessageBox "No file selected"

Exit Sub

End If

'**** do something

End If

End Select

End If

End If

End Sub