Tissot Posted November 27, 2006 Posted November 27, 2006 (edited) 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 November 27, 2006 by Guest
Wim Decorte Posted November 27, 2006 Posted November 27, 2006 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?
Tissot Posted November 28, 2006 Author Posted November 28, 2006 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
Wim Decorte Posted November 29, 2006 Posted November 29, 2006 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)
_ian Posted November 29, 2006 Posted November 29, 2006 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
Tissot Posted November 29, 2006 Author Posted November 29, 2006 (edited) 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 November 29, 2006 by Guest
Brudderman Posted November 29, 2006 Posted November 29, 2006 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.
Wim Decorte Posted November 30, 2006 Posted November 30, 2006 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
Recommended Posts
This topic is 6611 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 accountSign in
Already have an account? Sign in here.
Sign In Now