Hi
I am looking for a way to open the MS-Filesearch-Dialog out of a form, get a filename, and copy the name into a Table.
The reason is the following:
I export a debitor-adress to a word-dot file from out financials.
It works fine. I have a table where the adress of the documents and the name can put in.
But till now he have to type the adresses and the document name by hand and this is not very confortable.
My Idea is to give the user an open-file dialog where he can browse through his drives and mark the file he want to take into this list.
Does anyone has an idea?
Thomas Blang
0
Comments
Create a TextBox, set LookUp = Yes (gives a permanent lookup arrow), and set as source expression the variable FileName (text, 250).
Furthermore, create a variable BrowseDialog (OCX, Microsoft Common Dialog, COMDLG32.OCX)
In the OnLookUp trigger you put the following code:
BrowseDialog.DialogTitle := 'Select your file';
BrowseDialog.InitDir := 'C:\';
BrowseDialog.Filter := 'Text files|*.txt|All files|,*.*';
BrowseDialog.ShowOpen;
FileName := BrowseDialog.FileName;
Now when you user clicks the lookup arrow, the familiar Windows filedialog pops up and you get the FileName back. Empty means the user cancelled the action.
Note: You need to have a COMDLG32.OCX with Developers License to create the control, not to use it. A developers license common dialog is included with i.e. Visual Basic, Visual C++ etc.
John
It works fine but there is another problem too. When I export the objects and use it on an other machine I became an error-massage.
I have to put the COMDLG32.OCX onto this machine and have to register this OCX in Financials. Then it will work.
On the other side there is a Browse-dialog in the custom control menu, but I cannot open it to see how they have done it.
The other think is: Is it legal to give this OCX to our customers?
Any Ideas?
Thomas Blang
Not 100% sure (no system around without VB installed at the moment), but I believe it's sufficient to register in Navision the COMDLG32.OCX which is standard part of Windows, to use the control.
Might be a matter of version though, to get it working (you need Common Dialog 6.0). As the common dialog is a standard part of Windows, I don't think there's an objection against distributing it for this purpose; the alternative would be that you user is updating Windows by free downloads from the Microsoft site.
The browse dialog you get in the Customs Tools window, or the Request Form for that matter, is also the standard Windows common dialog, only difference is that NF is calling it directly.
John
And how is it in a network-installation? Have I to update every Workstation?
Thomas Blang
That's quite obvious: Yes.
But then again it's probably better to tell the system administrator to do his job properly, and get him to update the workstations to a more recent Windows version.
John
System Administrator???
Updated Windows versions???
Can I come work in your world? <img border="0" title="" alt="" src="images/smiles/icon_wink.gif" />
-jp
But if it's that bad in your world, your company has a good opportunity for generating extra business: Offer the customer to work as their system administrator <img border="0" title="" alt="" src="images/smiles/icon_biggrin.gif" />
John
I don't have the code handy but it's rather straight forward :
1/ Declare a global of type Record, Record Name = OLE Control
2/ set a filter on the name of the OLE control you want to register
and then you've got to do something like
IF NOT recOleControl.FIND('-') THEN
SHELL('regsvr32 c:\windows\system\yourocx.ocx');
tarek_demiati@ureach.com
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by John Tegelaar:
Thomas,
That's quite obvious: Yes.
But then again it's probably better to tell the system administrator to do his job properly, and get him to update the workstations to a more recent Windows version.
John<HR></BLOCKQUOTE>
I recently created a processing report that also saves som data in a text file.
To alow the user to specify the location and name of the file that the report creates I did the folowing:
1. Added a text box to the reports requestform.
2. Sett the "AssistEdit" property of the text box to "Yes"
3. In the "OnAssistEdit" trigger of the text box I added a local variable of type Codeunit, subtype "Common Dialog Management"
4. Added a call to this codeunits function "OpenFile"
5. Saved the returnvalue of the function in a global variable of type Text.
6. Used the global variable as SourceExpression for the text box.
The codeunit uses the same OCX as described in prevoius posts. Since the codeunit is already compiled I can use this methode even though I don't have a developers license. Also I dont have to install VB.