November 12, 200520 yr Microsoft offers a free Access database with some 2000 useful VBscripts. They were kind enough to allow me to rework this as a FileMaker database and make it available to the FileMaker community. You will find it in the downloads section of my website. Enjoy, Wim. Wim Decorte www.connectingdata.com T +49 (0)8024 3030752 F +49 (0)8024 3030753 Certified FileMaker 7 Developer
November 23, 200520 yr Thanks, Wim! I have downloaded and looked through it. Though I'm familiar with VBA in Excel, VBScript is new to me. But the syntax looks quite similar. So if you don't mind, let me ask a question about VBScript which will expose my ignorance. : Is there a way to use VBScript to pull the text of a web page into a FM field? Or, alternatively, to save the web page text as a file so that I could import it into a field? Thanks!
November 23, 200520 yr Thanks very much for this, Wim!! VBscripts offer such flexibility and control. The backup routines have saved me already! Your website is a beautiful collection of invaluable developer tools and I plan to take advantage of every one of them. :wink2:
November 24, 200520 yr Author Is there a way to use VBScript to pull the text of a web page into a FM field? Or, alternatively, to save the web page text as a file so that I could import it into a field? Most definitely. It will require talking to IE (Internet Explorer) but it can certainly be done. Let me see if I can find an example... The challenge will be to get the data into FM. Unless you're willing to paste, you'll need to go through the import engine. That means you can't have returns in the data or fm will create different records. You'll need to have the VBscript replace all returns with something else and then have FM substitute those out again to put the returns back in.
November 24, 200520 yr Author Thanks, LaRetta! Feel free to ask for stuff based on what you see. You might just get it Wim.
November 25, 200520 yr Author As a matter of fact, there is a script in the repository that does this. Look for "List the Contents of a Web Page" in category "scripting techniques". If you don't like that one, here's another (below). You'd need to add code to output the text to a text file (see the repository) and then have FM import it. You can even have the VBscript call the FM import script to solve any timing issues. ' *************************************************** ' ' VBScript to grab the content of a web page ' ' Author: Wim Decorte ' Date: Friday, November 25, 2005 ' Version: 1.0 ' ' *************************************************** Option Explicit Dim oIE Dim webPage Set oIE = CreateObject("InternetExplorer.Application") oIE.Visible = True oIE.Navigate("http://www.connectingdata.com/") ' loop until the page is loaded While oIE.Busy Wend ' if you want the full html: ' webPage = oIE.Document.DocumentElement.OuterHtml webPage = oIE.Document.DocumentElement.innertext MsgBox webPage oIE.Quit Set oIE = Nothing
November 25, 200520 yr Hi Wim: Have you seen a script that disables the Windows Close button on the main Filemaker Window? I use Dacons Menu Control which removes the Windows widgets from the individual files, but not the main window. Thanks, Steve
November 26, 200520 yr Author Nope, you need to talk to the Windows API to make that happen. VBscript can't talk to the API directly. VB and other real programming languages can. So you could write a tiny VB app that does it and use a Send Event from inside FM to run it. To ease deployment you can put the VB app in a container and use the "export field content" to put the vb app on the hard disk before running it.
November 26, 200520 yr Thanks anyway Wim, but I can do it from within WinBatch. It seemed to work in runtimes from v6...haven't tried it in v8 yet. What I noticed is that it takes a while to execute (only about 5 statements) a call to 'User32.dll'. Steve
November 27, 200520 yr Author Yes, that's one of the disadvantages of WinBatch. The executables are generally large (over 1MB) and slow to execute. A comparable VB application would a whole lot faster and would come in under 100Kb. Different learning curve though. But I must say learning VB and VBscript go hand in hand and it's not called Basic for nothing :)
November 27, 200520 yr You've made this comment before, but I have to strongly disagree with you. I have written many WB utilities all of which (except for the one we are currently discussing) are small and run very rapidly. Since most have fewer than 20 lines, I incorporated groups of scripts into one source file, which might have a length of 1500 lines. To call an individual script, all I do is pass the .exe a command line parameter telling it which of the scripts to execute. These compile rapidly (under a minute), and the .exe are in the 150k size. I don't include any extenders in the compiled .exe, preferring to put them on the user's disk using an installer. I think what you're seeing is the source plus however many extenders the source refers to, linked into 1 .exe. The first time the WB is run, it auto-exports the attached extenders into the folder, but the extenders are still present within the .exe. That is what accounts for the large .exe size. I find WB very efficient, requiring minimal scripting, covering a wide range of functionality, and great customer support. It is a great tool for working with FM limitations.
November 29, 200520 yr Thanks, Wim! Your VBScript for pulling the text of a web page is nice! I'm not familiar with the object model of IE, but from your statement MsgBox WebPage I had though that WebPage might be a string to which I could apply the Copy method (i.e., WebPage.Copy) to put the text on the clipboard, but that doesn't work. But if I could have the VBScript copy to the clipboard, I could have FM paste into a field and parse parse the web page instead of having another VBScript deal with the returns. Any suggestions on the Copy? You can even have the VBscript call the FM import script to solve any timing issues. How would this be done? Thanks so much for the help! James
November 29, 200520 yr Without trying this I would bet that you could have the VBScript dump the contents of the web page into a text file and then you could script FileMaker to import the contents of the text file into a global field. I haven't tried this but I think I would try this method and not mess around with the clipboard at all.
November 29, 200520 yr Ted, I have modified Wim's code to dump the results into a text file as follows: ' ********************************************* ****** ' ' VBScript to grab the content of a web page ' ' Author: Wim Decorte ' Date: Friday, November 25, 2005 ' Version: 1.0 ' ' ********************************************* ****** Option Explicit Dim oIE Dim webPage Dim objFSO, objFile Const ForWriting = 2 Set oIE = CreateObject("InternetExplorer.Application") oIE.Visible = True oIE.Navigate("http://www.ConnectingData.com/") ' loop until the page is loaded While oIE.Busy Wend ' if you want the full html: ' webPage = oIE.Document.DocumentElement.OuterHtml ' webPage = oIE.Document.DocumentElement.innertext ' MsgBox webPage Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.CreateTextFile ("C:results.txt", ForWriting) objFile.Write oIE.Document.DocumentElement.innertext objFile.Close oIE.Quit Set oIE = Nothing Though I haven't tried an import yet, Wim pointed out that the returns in this file will create separate records when imported. So the returns need to be replaced with something else before import. I don't know enough about VBScript at this point to know if that would require a separate script or if I could perform the operation within the same script. Seems like copying the text and pasting it might save that operation.
November 29, 200520 yr Since I don't seem to be able to edit or delete my last post, here is Wim's code further modified to replace the returns with pipes so that an import of the file will be in a single record. ' ********************************************* ****** ' ' VBScript to grab the content of a web page ' ' Author: Wim Decorte ' Date: Friday, November 25, 2005 ' Version: 1.0 ' ' ********************************************* ****** Option Explicit Dim oIE Dim webPage Dim objFSO, objFile Const ForWriting = 2 Set oIE = CreateObject("InternetExplorer.Application") oIE.Visible = True oIE.Navigate("http://www.ConnectingData.com/") ' loop until the page is loaded While oIE.Busy Wend ' if you want the full html: ' webPage = oIE.Document.DocumentElement.OuterHtml webPage = oIE.Document.DocumentElement.innertext ' MsgBox webPage Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.CreateTextFile ("C:results.txt", ForWriting) objFile.Write replace(webpage,vbcrlf,"|") objFile.Close oIE.Quit Set oIE = Nothing
November 30, 200520 yr Author Good responses so far. I'm not a big fan of using the clipboard but if you want to use it, add this line right after capturing the web page: oIE.document.parentwindow.clipboardData.SetData "text", webPage Then you go can switch to FM and paste, or even have the VBscript call a FM script that goes to the right field and does a paste. Note that using the clipboard can be turned off in the security settings of IE so it is not guaranteed to work...
November 30, 200520 yr Author Some more general info: Unlike real VB, VBscript can not touch the clipboard directly. The only way is to use IE to do it for you like in this example.
November 30, 200520 yr Thanks, Wim! I've learned a lot through this exercise. even have the VBscript call a FM script How do I get VBScript to call a script in FM? Thanks!
November 30, 200520 yr Author This is a standalone script so you'd to work this into whatever VBscript you want to use it. Check the FM help file for "activeX" to read an overview of all the FM objects and methods. The examples give are for VB and VBA not VBscript so you'd need to do minimal changes to make the examples work in VBscript. ----------------------------------------------- Dim fmApp, fmDocs, fmDoc Set fmApp = CreateObject("FMPRO.application") fmApp.Visible = True Set fmDocs = fmApp.Documents ' typically you'd check here for fmDocs.count ' to see if FM even has files open ' hooks into the active doc ' loop through the docs and check for names if you want ' to target a specific one Set fmDoc = fmDocs.active ' don't forget to check for scriptstatus before you do this ' calling a script from the outside *will* interrupt ' any running script fmDoc.dofmscript("theScript") ' clean up Set fmDoc = Nothing Set fmDocs = Nothing Set fmApp = Nothing -----------------------------------------------
November 30, 200520 yr Brudderman, Take a look at the downloads section on Wim's site - near the bottom of the list. I believe that he has an example there. I also think there is an example in FileMaker help. There was in v7, I assume it's there in v8 too although the v7 version was written for Visual Basic not VBScript if my memory serves me.
November 30, 200520 yr Thanks, Ted. I hadn't seen it on Wim's site before, but sure enough, there it is! I also had a look at the script for Microsoft Office VBA. Very nice. I appreciate the pointer.
Create an account or sign in to comment