Page 1 of 1

How to open FC via VBA

Posted: 16.01.2014, 08:15
by IVY440
In our office we use an Access database with its forms and VBA code as a central navigation panel (open maps, open files, open contacts,...).

To open maps we used to use Windows Explorer. More and more people are starting to use FreeCommander but we experience a problem with it.

In a linked table in another database the general pathnames are stored. Because of the structure of our network and mapnames, there are a lot of spaces in the names of the maps. When we use the following code in VBA to open a map with FreeCommander and there is a space in the pathname, FreeCommander opens the path until the first space.

How can we resolve this problem?

Code: Select all

pad = (Me![Pathname]) & "map to open"
    
    If Dir("C:\Program Files (x86)\FreeCommander XE\FreeCommander.exe") <> "" Then
    stAppName = "C:\Program Files (x86)\FreeCommander XE\FreeCommander.exe " & pad
    Call Shell(stAppName, 1)
    Else
    If Dir("C:\WINDOWS\explorer.exe ") <> "" Then
    stAppName = "C:\WINDOWS\explorer.exe " & pad
    Call Shell(stAppName, 1)
    Else
    MsgBox (" Message")
    End If
    End If

Re: How to open FC via VBA

Posted: 16.01.2014, 15:41
by BGM
Ah, so you want to interface FC from an external source?

I came up with a little utility to perform various tasks with FC from the commandline.

Check out my little program called Freund:
http://www.sspxusa.org/goodies#freund

The way it works is this: there are two programs. One runs in the background and performs the tasks. The other one is the commandline application that will allow you to send commands to the running application.

Freund reads your custom hotkeys and sends keycommands to FC. So if you change your hotkeys, Freund should, concievable, accomodate.

So, you can create tabs, open directories, and some other things. I did write some online documentation, but I haven't publicized it anywhere because it's not refined yet.

I haven't tried it with the last two releases, and it's really just beta. I use it myself, however. You are welcome to try it.

Re: How to open FC via VBA

Posted: 16.01.2014, 21:07
by IVY440
Thanx. We will try if it works.

But what we really try to do is open a directory (with sadly enough spaces in the pathname) with FreeCommander.

When we do it with the mentioned code (eg when the pathname is C:\Documents and settings\Document.docx), FreeCommander tries to open the directory before the space (in the example : C:\Documents) which in most cases doesn't exist. We figured out it's because of the space in the pathname. Is there a VBA code which we can use to avoid the mentioned problem?

Re: How to open FC via VBA

Posted: 16.01.2014, 21:19
by BGM
Put double-quotes around the file/directory path.

You do have double quotes - but they are there to tell VBS you are using a string. You need another set of double-quotes INSIDE the ones you have, but you'll have to escape them - probably with a backslash, like this: "\"string\""