Jump to content

Desperate Mac girl needs help


Irenem
 Share

This topic is 5669 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I have a script that inserts files (only the reference) in a container field, then he copy them from the original location to a folder on the server.

When I delete the record I want FileMaker to delete also the file on the server.

On the Mac is just working fine with an AppleScript, but I don’t have a clue how to let this work on a Windows XP.

Any help would be great.

Link to comment
Share on other sites

if you have the full path to the original location then you can use the Send Event script step to call the Windows command line. The command to execute looks like this:

cmd /c del c:someFoldertheFile.ext

Or if there are spaces in the file name or folder name:

cmd /c del "c:some foldersome file.ext"

This line can be calculated based on your data. Use the Quote() function to wrap the last part in quotes.

In the Send Event script step, uncheck the "bring target application to the front" and the user will not see anything happening.

Link to comment
Share on other sites

Wim,

Thank you, it works just fine.

Now I have to do some more things as run a vb script in Word to merge fies and rename documents. I don't wont to bother you with a lot of questions. May be you know where I can find some documentation about Windows automation and FileMaker.

Link to comment
Share on other sites

No problem, ask away. That's why we're here.

Not many info available on Windows automation & FileMaker. I've written some articles in Advisor Magazine on the subject but that info is dated now (was for FM6). Things are somewhat easier in FM8.

Link to comment
Share on other sites

Thank you,

I will try to explain what I am trying to do:

I have a file with customers. From this file I can write documents with word (FileMaker is not really a word processor).

FileMaker generates a data document and put it in a specific folder on a server. Then AppleScript opens a specific template in Word that contains an AutoRun macro that merges the two documents, closes the template and save the merged document with a specific name passed by a variable in FileMaker in a document folder

To make it clear here is the script:

If [ Get ( SystemPlatform )=-1 ]

Set Variable [ $$Source; a_folder_on_the_server]

Export Records [ File Name: “filemac:/$$Source/Data.htm”; Character Set: “Macintosh”;

Perform AppleScript [ Calculated AppleScript: " tell application "Microsoft Word"

activate

open "The_Template:"

set default file path file path type documents path path "The_Document_Folder"

save as active document file name ""

close document "The_Template"

end tell

tell application "Finder"

move document file "iAssist:TestTemplates:Data.htm" to trash

end tell

End If

Here is what I have written till now for Windows.

If [ Get ( SystemPlatform )=-2 ]

Set Variable [ $$Source; a_folder_on_the_server ]

Export Records [ File Name: “filewin:$$Source/Data.htm”; Character Set: “Windows

Send Event [ open document; """ Path_to_the_Template_Folder ; "/" ; "") & "" & The_Template & """ ]

End If

The first problem is that the template opens with a message

“If you open this document the following SQL-command wil be executed:

SELECT*FROM ….Path

Data from the database will be placed in the document. Do you want to continue?”

Of course I want, and I don’t want to be asked all the time. I have the Macro security set to a minimum but this message is still showing. When I open the same document on a Mac it’s no problem.

The second problem is that I have to close the template and save the merged letter with a name passed by FileMaker and I don’t know the syntax.

I’ve looked on the Internet but I can’t find a basic vocabulary for C.

I feel like an idiot!!

Link to comment
Share on other sites

I’ve looked on the Internet but I can’t find a basic vocabulary for C.

No need for C. The equivalent to AppleScript is VBscript. (www.microsoft.com/scripting).

Part of your problem is that you have code in two places: some in the applescript, some embedded in the Word document (VBA).

As long as you have code embedded in the document you will have problems on Windows with security warnings, unless you digitally sign your code with a certificate from Verisign or Thawte. Expensive, but that's the price we all have to pay for security.

A better solution would be to keep all the code in one place. All in Applescript on the Mac and all in VBscript on Windows. You can put VBA code directly in Applescript. And from VBscript you touch all of Word's features.

Executing the VBscript from inside FM can be difficult, especially if you want a result back inside FM. Check out the VBscript plugin page http://grokittools.com for some pointers and links to more info on both VBscript and where to find info on using Office applications with VBscript.

Link to comment
Share on other sites

  • 2 weeks later...

A little bit late... but Thank you! Great tool!

It works easely, but I have still some problems with the syntax. I could figure out how to open my template.

"Set objWord = CreateObject("Word.Application")

objWord.Visible = True

Set objDoc = objWord.Documents.Open("ServeriassistTestTemplatesVLS_Letter3.dot")"

But now I have to open the data source and merge the two documents. I have no clue how to do that.

May be you can help.

Link to comment
Share on other sites

In the most general terms, this is how it's done:

Set objWord = CreateObject("Word.Application")

Set objDoc = objWord.Documents.Open(TemplatePath)

objDoc.MailMerge.OpenDataSource DataPath

objDoc.MailMerge.Execute

Do a search on your machine for "*VBA*.chm". One of the files will be the full Word VBA model, with lots of example code. Do a search in there for "MailMerge".

Note that the examples in the help file are all for VBA, not VBscript so small changes may be necessary. Let us know where you get stuck.

Link to comment
Share on other sites

You need to do a "SaveAs", check the Word VBA help file for the correct syntax and the options. The options you need (off the top of my head) are filetype and location/name.

fun, isn't it :

But don't give up, it's very rewarding. You can actually use the VBA syntax inside AppleScript so everything you're learning here is not wasted.

Link to comment
Share on other sites

This topic is 5669 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.