# Opening external documents

**URL:** <https://forum.servoy.com/t/opening-external-documents/8531>\
**Category:** Classic Servoy\
**Created:** [December 17, 2007, 3:14pm UTC](https://forum.servoy.com/t/opening-external-documents/8531 "2007-12-17T15:14:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![irenem](https://avatars.discourse-cdn.com/v4/letter/i/977dab/32.png) [@irenem](https://forum.servoy.com/u/irenem)\
**Post date:** [December 17, 2007, 3:14pm UTC](https://forum.servoy.com/t/opening-external-documents/8531/1 "2007-12-17T15:14:44Z")

</div>

I have a database with a media-field in which I store all kind of documents (pdf’s, images, word documents etc.).

In FileMaker you can double-click on the document and he will recognize the application he needs to open without writing any methods.

I understand that Servoy doesn’t has this feature yet.

Is anybody there with a suggestion how to do that with a method?

Will this feature be available in Servoy 4.0?

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [December 17, 2007, 3:18pm UTC](https://forum.servoy.com/t/opening-external-documents/8531/2 "2007-12-17T15:18:03Z")

</div>

Try this

```auto
var vFilePath = "path to the file"
if (utils.stringMiddle(application.getOSName(), 1, 7) == 'Windows') {
	application.executeProgram('rundll32', 'url.dll,FileProtocolHandler', vFilePath)
} 
else if (utils.stringMiddle(application.getOSName(), 1, 3) == 'Mac') {
	application.executeProgram('open', vFilePath);
}

```

---

<div class="post-metadata">

**Author:** ![irenem](https://avatars.discourse-cdn.com/v4/letter/i/977dab/32.png) [@irenem](https://forum.servoy.com/u/irenem)\
**Post date:** [December 17, 2007, 3:37pm UTC](https://forum.servoy.com/t/opening-external-documents/8531/3 "2007-12-17T15:37:44Z")

</div>

```auto
var vFilePath = "path to the file"

```

I guess I don’t have a path, my documents are stored in the database, not only linked. I do this to be enable the web-client to download them.

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [December 17, 2007, 3:46pm UTC](https://forum.servoy.com/t/opening-external-documents/8531/4 "2007-12-17T15:46:29Z")

</div>

If you have stored your document in a blob, then you need to write it to disk first. See the file plugin methods. The file plugin allows you to create a temp file. That file’s path can be used then…

---

<div class="post-metadata">

**Author:** ![irenem](https://avatars.discourse-cdn.com/v4/letter/i/977dab/32.png) [@irenem](https://forum.servoy.com/u/irenem)\
**Post date:** [December 18, 2007, 10:06am UTC](https://forum.servoy.com/t/opening-external-documents/8531/5 "2007-12-18T10:06:28Z")

</div>

I’ve tried the writeFile plugin, but I’m having some problems.

```auto
var filePath = 'MyHardisk/MyFolder/test.doc'
var success = plugins.file.writeFile(filePath,forms.action_list.act_document);
if (success)
{ plugins.dialogs.showInfoDialog('Export', 'File OK', 'OK');
}

```

I get no warnings, the dialog says “File OK” but I can’t find any file in MyFolder.

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![ars](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@ars](https://forum.servoy.com/u/ars)\
**Post date:** [December 18, 2007, 10:12am UTC](https://forum.servoy.com/t/opening-external-documents/8531/6 "2007-12-18T10:12:19Z")

</div>

> irenem:  
> I’ve tried the writeFile plugin, but I’m having some problems.
> 
> ```auto
> var filePath = 'MyHardisk/MyFolder/test.doc'
> 
> ```

var success = plugins.file.writeFile(filePath,forms.action\_list.act\_document);  
if (success)  
{ plugins.dialogs.showInfoDialog(‘Export’, ‘File OK’, ‘OK’);  
}

> ```auto
> 
> I get no warnings, the dialog says "File OK" but I can't find any file in MyFolder.
> 
> What am I doing wrong?
> 
> ```

I think, the file hasn’t been created yet. First create the File then write into that.

```auto
var filePath = 'MyHardisk/MyFolder/test.doc'
var file = plugins.file.createFile(filePath);
var success = plugins.file.writeFile(file,forms.action_list.act_document);
if (success)
{ plugins.dialogs.showInfoDialog('Export', 'File OK', 'OK');
}

```

---

<div class="post-metadata">

**Author:** ![irenem](https://avatars.discourse-cdn.com/v4/letter/i/977dab/32.png) [@irenem](https://forum.servoy.com/u/irenem)\
**Post date:** [December 18, 2007, 10:23am UTC](https://forum.servoy.com/t/opening-external-documents/8531/7 "2007-12-18T10:23:50Z")

</div>

Than you ars,

I’ve tried your suggestion. No go, the result is the same.

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [December 18, 2007, 10:32am UTC](https://forum.servoy.com/t/opening-external-documents/8531/8 "2007-12-18T10:32:02Z")

</div>

Your path looks strange. What system are you on? On windows, it should look something like C:.…, and on the Mac I think it should be /Volumes/myHardDisk/…

---

<div class="post-metadata">

**Author:** ![irenem](https://avatars.discourse-cdn.com/v4/letter/i/977dab/32.png) [@irenem](https://forum.servoy.com/u/irenem)\
**Post date:** [December 18, 2007, 11:00am UTC](https://forum.servoy.com/t/opening-external-documents/8531/9 "2007-12-18T11:00:20Z")

</div>

I’m on a Mac. You are right, it works heavenly now.

Thank you
