Macros and Programming


CardboxForumsMacros and Programming > "Open existing excel doc using a macro button"

Open existing excel doc using a macro button

Open existing excel doc

Posted By Post


11-Nov-2008 13:01

I am evaluating Cardbox for my company and trying to open an Excel file for viewing by using a macro that uses a field contents as the excel file name.This file is already created.I am new to macro programming and not sure about running other apps from within Cardbox.Any help would be much appreciated


11-Nov-2008 13:21

No macro needed.

Just type in a field file:d:\folder\workbookname.xls.

Dubbleclick with your mouse on the filename and volia....


11-Nov-2008 13:40

The actual Excel doc is already created and the field has just the ref no(indexed).What I want to do is have a seperate button which runs a macro.
The macro needs to open the excel file using the contents of the field as the excel filename.This field will have different contents each time as it is automatically created.Is this possible.Looking on the forum there is a similar question about word.Have tried modifying that one but as I said,I am new to macro programming.


11-Nov-2008 14:25

ok, use this line

launch """c:\my documents\" & trim(fields("yourfieldname") & ".xls"""
if Excel correct is installed, Excel will start.
Quotes are added for avoiding problems with path or filesnames containing spaces.

If Excel not correct is installed you need to use this:
launch "yourpath\excel.exe","""c:\my documents\" & trim(fields("yourfieldname") & ".xls"""


Mary Doyle

11-Nov-2008 21:31

The following will also work and you don't need to worry about the quotes and how many to use

You have 2 fields - one for the path to the file (PT) and 1 for the filename (FL)

PathOfFile = Fields("pt")
FileToOpen = Fields("fl")
Launch PathOfFile & FileToOpen

Depending on your system the "My Documents" path may be a bit more complicated that Bert's example e.g. it might be something like C:\Documents and Settings\MD\My Documents\. If you

right click on the actual file and look at properties you will see the full path.


14-Nov-2008 11:24

Many thanks,both methods do exactly what I need them to.
Thanks for all the help

© 2010 Cardbox Software Limited   Home