Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

A small automation for Word

Featured Replies

Hello guys.

I'm trying to get FM run a VBS Script that does the following:

1. Open an existing Word Doc

2. Enter the address in a text field

3. Enter the date

4. Enter the Customer number

5. Enter Quote number

6. Save the Doc to the this formula: Quote-Nr. & ", " & Name & ", " & Place & ", " & Get(CurrentDate)& ".doc"

7. Leave the Doc Open and ready for editing

Any Help would greatly be appreciated.

Thanks in advance.

Best regards.

Ron

Edited by Guest

Hi Ron,

When you talk about inserting data into Word "fields" you're really talking about merging data.

Nothing wrong with that but the data source needs to exist. So either you use an ODBC connection back to FM for that (works, but may be total overkill for what you want) or you need to have FM export a small text file first, then execute a VBscript to tell your word document to merge with that text file. Your VBscript can then save the document and leave it open.

so #3 to 5 are handled by the merging. #1 and 6 are relatively straightforward. How much of this do you already have in your VBscript?

  • Author

Hi Wim Decorte,

sounds good, I like the version with a Text file, I even tried to do that but I'm no good at VB. I've got some sort of VBS Script written but not worth looking at.

I would greatly apreciate you’re help.

Regards

Ron

Hi Ron,

I can't obviously write it for you unless you hire me too ;)

Here's how you can attempt it yourself:

- export the text file from filemaker

- in your word document, put on the VBA recorder and go through the whole merge setup, including the final merge

- this will give you VBA code that pretty much does what needs to be done

- you can then use that VBA code to write similar VBScript code.

- (and remove the VBA code from your word document otherwise you'll keep getting security prompts)

THERES A VBA RECORDER?;)

Where's that at?

The record new macro command under the tools menu. Once you've recorded a macro you're able to open it and view the VBA source.

hth

Ian

  • Author

Hey, thats exactly what I did... hmm I'll give it another try.

Seeya

EDIT: Can you PLEASE give me a clue how to get Word to open and save something ?

Edited by Guest

When you record, however, realize that the resulting VBA code (in Word and Excel) will likely be quite verbose with lots of extra and unnecessary statements. So try to clean those up before converting to vbs. The recording just gives you a jumpstart.

do a search on your machine for *vba*.chm and you'll find one that describes the full Word object model. It's chock full of code examples.

Note that the examples are for VBA, not VBscript but the main difference is that in VBscript:

- you do not type variables

- you can't use named constants. The numerical equivalent of the named constants are also listed in that help file

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.