cancel
Showing results for 
Search instead for 
Did you mean: 

How to display the open file dialogue in SBO 2007

Former Member
0 Kudos

Hi

I have my own form on screen with a edit text box which will contain the path and name of a file entered by the user

Is there any way I can display the windows open file dialogue so the user can search for a file ?

Many thanks

Regards Andy

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Check the following threads..... they may help u..

Hope they help u..

Vasu Natari.

Former Member
0 Kudos

HI ,

find this link its in c#

Rgds

Micheal

Former Member
0 Kudos

Hi

Thanks for all your answers

After searchiing a bit more the easiest option which doesn't even need coding is to define a link udf and then bind that to an edit box on the form

If you double click a file browser is displayed

Many thanks

Regards Andy

former_member185703
Active Contributor
0 Kudos

Hi Andy,

Please note that using this built-in functionality has one disadvantage:

It will copy the file you choose into the Attachments folder of SAP Business One...

If this is OK for you - great...

Sorry,

Frank

Former Member
0 Kudos

Hi Frank

Just noticed that, it's ok but ideally I want just to open a file dialogue windows to search for a file

I have tried Anoop's solution but having problems

Could you recommend a simple solution that works please ?

Regards Andy

former_member185703
Active Contributor
0 Kudos

Hi Andy,

This suggestion (from Denis Sapunkov) seems to work quite well:

We are using sth similar in Custom Help Mapping - source code available here (file: Button__SAP_CustomHelpMap__SAP_CHPATH.cs):

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f011fa21-3c06-2c10-7ab2-d2051fdc...

HTH,

Frank

Answers (2)

Answers (2)

Former Member
0 Kudos

Reopnened as using the link solution always copies file to attachment folder

former_member682029
Contributor
0 Kudos

Hi..

I imagine you are using C# or VB.net.

You can use this method

OpenFileDialog f = new OpenFileDialog();

f.ShowDialog();

Before doing this you must do the steps provided in this thread.

Anoop

Former Member
0 Kudos

Hi Anoop

Sorry for the delay as I thought the solution using a SAP link udf would work, which it does but it always copies the file to the attachment folder

Just tried your solution but I am getting the following message -

Current thread must be set to single thread appartment (STA) mode

Any ideas please ?

Copy of my vb code below -

abform = New Form1

abform.Show()

abform.ShowReportMainFunction()

Dim openfiledialog1 As New Windows.Forms.OpenFileDialog

openfiledialog1.ShowDialog()

Dim callFunction As Windows.Forms.MethodInvoker = New Windows.Forms.MethodInvoker(AddressOf ShowReport) 'ERROR HERE

'In the ShowReport Function

Public Sub ShowReport()

Me.OpenFileDialog1.ShowDialog()

End Sub

'Main function to Invoke the MethodInvoker

Public Sub ShowReportMainFunction()

Me.BeginInvoke(callFunction)

End Sub

Regards Andy

former_member682029
Contributor
0 Kudos

Which version of VS you are using. This error is a common visual studio error. you can solve this by setting the apartment to single.

Just do a Google search on how to set this.

Anoop

Former Member
0 Kudos

Hi Anoop

I am using vb.net 2005

Thanks

Regards Andy

Former Member
0 Kudos

Hi Anoop

I have googled but still unsure of what I need to do, can you or anyone help please ?

Regards Andy

Former Member
0 Kudos

Hi Anoop

I have found something via google

Thanks for your help

Regards Andy

former_member682029
Contributor
0 Kudos

Good That is interesting.

What did you find?

Anoop

Former Member
0 Kudos

Hi Anoop

Code below, simple and it seems to work well

Thanks for your help

Regards Andy

fpath = ""

Dim thread As New System.Threading.Thread(AddressOf openfile)

thread.SetApartmentState(Threading.ApartmentState.STA)

thread.Start()

thread.Join()

form.Items.Item("4").Specific.string = fpath

Sub openfile()

Dim abform As Form1

abform = New Form1

abform.Show()

abform.OpenFileDialog1.Filter = "CSV Files|*.csv"

If abform.OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then

fpath = abform.OpenFileDialog1.FileName

End If

abform.Close()

End Sub