November 27, 200619 yr 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, 200619 yr by Guest
November 27, 200619 yr 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?
November 28, 200619 yr 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
November 29, 200619 yr 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)
November 29, 200619 yr 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
November 29, 200619 yr 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 November 29, 200619 yr by Guest
November 29, 200619 yr 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.
November 30, 200619 yr 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