Jump to content

randlem

Members
  • Content count

    19
  • Joined

  • Last visited

Community Reputation

0 Neutral

About randlem

  • Rank
    member
  1. randlem

    VBScript & ActiveX

    Hi, I did set/declare 'objFM': Set objFM = WScript.CreateObject ('FMPRO.Application')¶ Set objFMfiles = objFM.Documents¶ for each objTargetFile in objFMfiles¶ if objTargetFile.fullname = 'D&H Sales Database - Development.fmp12' then¶ objTargetFile.DoFMScript ('OpenAcknowledgementScript')¶ end if¶ next¶ Set objFMfiles = nothing¶ Set objFM = nothing¶ Set objTargetFile = nothing¶" But the script did not fire. Regards, Mark.
  2. randlem

    VBScript & ActiveX

    Hi Wim, I found some code on a google search that I had not spotted which works: Set FMApp = CreateObject('FMPRO.Application')¶ Set FMDocs = FMApp.Documents¶ FMApp.Visible = True¶ Set FMActiveDoc = FMDocs.Active¶ FMActiveDoc.DoFMScript ('OpenAcknowledgementScript')¶ Set FMDocs = Nothing¶ Set FMActiveDoc = Nothing¶" Many thanks for all you help. Kind regards,
  3. randlem

    VBScript & ActiveX

    Hi Wim, Thanks for that. I tried the following code: Set objFMfiles = objFM.Documents¶ for each objTargetFile in objFMfiles¶ if objTargetFile.fullname = 'D&H Sales Database - Development.fmp12' then¶ objTargetFile.DoFMScript ('OpenAcknowledgementScript')¶ end if¶ next¶ Set objFMfiles = nothing¶ Set objFM = nothing¶ Set objTargetFile = nothing¶" I got a WSH error - Object Required 'objFM' Then I tried (with & without the .fmp12): Set objFM = WScript.CreateObject ('FMPRO.Application')¶ Set objFMfiles = objFM.Documents¶ for each objTargetFile in objFMfiles¶ if objTargetFile.fullname = 'D&H Sales Database - Development.fmp12' then¶ objTargetFile.DoFMScript ('OpenAcknowledgementScript')¶ end if¶ next¶ Set objFMfiles = nothing¶ Set objFM = nothing¶ Set objTargetFile = nothing¶" The error go but the objTargetFile.DoFMScript ('OpenAcknowledgementScript')¶ does not fire. Kind regards, Mark.
  4. randlem

    VBScript & ActiveX

    Hi Wim, Thanks for your response. Not too sure what you mean by "just loop through the FM documents collection until you have the right one targeted and then run the script" So is the code below what I should be looking at?. Set objFM = WScript.CreateObject ('FMPRO.Application')¶ If objFM.ScriptStatus = 0 then¶ Set objFMfiles = objFM.Documents.DoFMScript ('OpenQuotationScript')¶ objFM.Visible = True¶ End If¶
  5. Afternoon Guys, I could do with some help with following code: Set objFM = WScript.CreateObject ('FMPRO.Application')¶ If objFM.ScriptStatus = 0 then¶ Set objFMfiles = objFM.Documents.Open(‘Database.fmp12','un','pw')¶ objFM.Visible = True¶ objFMfiles.DoFMScript ('OpenQuotationScript')¶ End If¶ This code basically opens a word doc after it has had it's bookmarks populated and closed. The code works fine until a different user other than the one I used in the 'un' & 'pw' is logged in and then I get a WSH error. So is there a way of using the Set objFMfiles = objFM.Documents.Open(‘Database.fmp12','un','pw') without needing to use a username & password or somehow getting the Users username & password. I have tried using GetObject instead of Open but with no success. Any pointers would be most appreciated. Kind regards, Mark.
  6. randlem

    Open MS Word Document Using a VBScript

    Guys, I managed to sort it: Set objFM = WScript.CreateObject ('FMPRO.Application')¶ If objFM.ScriptStatus = 0 then¶ Set objFMfiles = objFM.Documents.Open(‘Database.fmp12','un','pw')¶ objFM.Visible = True¶ objFMfiles.DoFMScript ('OpenQuotationScript')¶ End If¶" Although it is very slow in eventually opening about 30s, not sure if that is because I testing over a vpn. Regards, Mark.
  7. randlem

    Open MS Word Document Using a VBScript

    Hi Wim, Could I trouble you for some assistance please ActiveX, Adding to my VBScript to run a Filemaker Script Please see my script below: #Define Sales Person's Full Name #Define VBScript filename relative to current user's Documents folder (e.g. typically filewin:/C:/Users/User/Documents/Generate_Word. VBS) Set Variable [ $VBSFilePath; Value:"filewin:" & Get(DocumentsPath) & "Generate_Word.VBS" ] #Define Output Word filespec relative to current user's Documents folder (e.g. typically filewin:/C:/Users/User/Documents/Word Sample.doc) Set Variable [ $WordFilePath ; Value:"/S:Dernier & Hamlyn Sales DocumentationQuotations/Quotation " & Quotes::Quote No & "-" & Quotes::Doc Num &".doc" ] Set Variable [ $PDFFilePath ; Value:"/S:/Dernier & Hamlyn Sales Documentation/Quotations/Quotation " & Quotes::Quote No & "-" & Quotes::Doc Num &".pdf" ] #Trim first character (slash) from filename so it is acceptable to Windows Set Variable [ $WordFilePath ; Value:Right ( $WordFilePath; Length($WordFilePath)-1 ) ] Set Variable [ $PDFFilePath ; Value:Right ( $PDFFilePath; Length($PDFFilePath)-1 ) ] #Define VBScript used to generate Word file. NOTE: For readability, single quotes are used Set Field [ Quotes::VBscript ; "Set oFileObj = CreateObject("Scripting.FileSystemObject")¶ Set WshShell = WScript.CreateObject("WScript.Shell")¶ Set objWord = WScript.CreateObject ("Word.Application")¶ Set objDoc = objWord.Documents.Open( "C:Dernier & Hamlyn Sales DatabaseTemplatesquotation template.doc",,True)¶ objWord.Visible = True¶ Set objRange = objDoc.Bookmarks('QuoteDate').Range¶ objRange.Text = '" & Quotes::FormatDate & "'¶ Set objRange = objDoc.Bookmarks('QuoteRef').Range¶ objRange.Text = '" & $QuoteRef &"' ¶ Set objRange = objDoc.Bookmarks('QuotePhone').Range¶ objRange.Text = '" &" " & Quotes::QuotelPhone & "'¶ Set objRange = objDoc.Bookmarks('QuoteClient').Range¶ objRange.Text = '" &Quotes::Client & "'¶ Set objRange = objDoc.Bookmarks('QuoteAddress').Range¶ objRange.Text = '" & Quotes::QuoteAddress1 & "'¶ Set objRange = objDoc.Bookmarks('QuoteAddress2').Range¶ objRange.Text = '" & Quotes::AddressL2 & "'¶ Set objRange = objDoc.Bookmarks('QuoteAddress3').Range¶ objRange.Text = '" & Quotes::AddressL3 & "'¶ Set objRange = objDoc.Bookmarks('QuoteAddress4').Range¶ objRange.Text = '" & Quotes::AddressL4 & "'¶ Set objRange = objDoc.Bookmarks('QuoteAddress5').Range¶ objRange.Text = '" & Quotes::AddressL5 & "'¶ Set objRange = objDoc.Bookmarks('QuoteName').Range¶ objRange.Text = '" & Quotes::QuoteContact & "'¶ Set objRange = objDoc.Bookmarks('Text1').Range¶ objRange.Text = '" &" " & Quotes::QuoteContact & "'¶ Set objRange = objDoc.Bookmarks('QuoteWeeks').Range¶ objRange.Text = '" & Quotes::Weeks & "'¶ Set objRange = objDoc.Bookmarks('SalesPerson').Range¶ objRange.Text = '" & $SP & "'¶ Set objRange = objDoc.Bookmarks('Position').Range¶ objRange.Text = '" & $Position & "'¶ objDoc.SaveAs( "C:Dernier & Hamlyn Sales DatabaseTest.doc")¶ objWord.Quit¶ Set FMProApp = GetObject('',"FMPRO.Application")¶ Dim FMProDoc¶ FMProDoc.DoFMScript ("MyScript")¶ Set FMProDoc = nothing¶" ] #Replace all single quotes with double quotes so that script executes under Windows Set Field [ Quotes::VBscript ; Substitute ( Quotes::VBscript; "'"; """ ) ] #Save VBScript and open it (automatically open must be checked, to open it (execute it) following its generation) Export Field Contents [ Quotes::VBscript ; “$VBSFilePath”; Automatically open ] The word document opens in the taskbar populates the bookmarks and saves the document with the required name. Then word closes. Then the code to run the filemaker script (which is a send event to open the word document) I get a windows script host error: Line: 38 Char: 2 Error: Object Required: '' Code: 800A01A8 Any pointers would be greatly appreciated Regards Mark.
  8. randlem

    Open MS Word Document Using a VBScript

    Is this what you are looking for: If [ Quotes::Doc Num>0 ] Show Custom Dialog [ Title: "Warning!"; Message: "Quote Document already created."; Default Button: “OK”, Commit: “Yes” ] Else If [ Quotes::Sales Person ="JQ" ] Set Variable [ $SP; Value:"Jeremy Quantrill" ] Set Variable [ $Position ; Value:"Director" ] Else If [ Quotes::Sales Person = "BS" ] Set Variable [ $SP; Value:"Brian Spiking" ] Set Variable [ $Position ; Value:"Director" ] Else If [ Quotes::Sales Person = "MH" ] Set Variable [ $SP; Value:"Mark Harper" ] Set Variable [ $Position ; Value:"Director" ] Else If [ Quotes::Sales Person = "NI" ] Set Variable [ $SP; Value:"Natalie Ions" ] Set Variable [ $Position ; Value:"Administrator" ] End If Set Variable [ $Date; Value:Get(CurrentDate) ] Set Field [ Quotes::Doc Num ; 1 ] Set Variable [ $QuoteRef ; Value:If (not IsEmpty ( Quotes::EB_NO ) ; Quotes::Sales Person & "/" & Quotes::EB_NO & "/Q" & Quotes::Quote No & "-" & Quotes::Doc Num ; Quotes::Sales Person & "/Q" & Quotes::Quote No & "-" & Quotes::Doc Num ) ] #Define VBScript filename relative to current user's Documents folder (e.g. typically filewin:/C: /Users/User/Documents/Generate_Word.VBS) Set Variable [ $VBSFilePath; Value:"filewin:" & Get(DocumentsPath) & "Generate_Word.VBS" ] #Define Output Word filespec relative to current user's Documents folder (e.g. typically filewin:/C:/Users/User/Documents/Word Sample.doc) Set Variable [ $WordFilePath ; Value:"///192.168.21.1/CompanyDernier & Hamlyn Sales DocumentationQuotationsWord/Quotation " & Quotes::Quote No & "-" & Quotes::Doc Num &".doc" ] Set Variable [ $PDFFilePath ; Value:"///192.168.21.1/Company/Dernier & Hamlyn Sales Documentation/Quotations/PDF/Quotation " & Quotes::Quote No & "-" & Quotes::Doc Num &".pdf" ] #Trim first character (slash) from filename so it is acceptable to Windows Set Variable [ $WordFilePath ; Value:Right ( $WordFilePath; Length($WordFilePath)-1 ) ] Set Variable [ $PDFFilePath ; Value:Right ( $PDFFilePath; Length($PDFFilePath)-1 ) ] #Define VBScript used to generate Word file. NOTE: For readability, single quotes are used Set Field [ Quotes::VBscript ; "Set objWord = CreateObject('Word.Application')¶ objWord.Application.Visible = True¶ Set objDoc = objWord.Documents.Open( '///192.168.21.1/CompanyDernier & Hamlyn Sales DocumentationTemplatesquotation template.doc',,True)¶ Set objRange = objDoc.Bookmarks('QuoteDate').Range¶ objRange.Text = '" & Quotes::FormatDate & "'¶ Set objRange = objDoc.Bookmarks('QuoteRef').Range¶ objRange.Text = '" & $QuoteRef &"' ¶ Set objRange = objDoc.Bookmarks('QuotePhone').Range¶ objRange.Text = '" &" " & Quotes::QuotelPhone & "'¶ Set objRange = objDoc.Bookmarks('QuoteClient').Range¶ objRange.Text = '" &Quotes::Client & "'¶ Set objRange = objDoc.Bookmarks('QuoteAddress').Range¶ objRange.Text = '" & Quotes::QuoteAddress1 & "'¶ Set objRange = objDoc.Bookmarks('QuoteAddress2').Range¶ objRange.Text = '" & Quotes::AddressL2 & "'¶ Set objRange = objDoc.Bookmarks('QuoteAddress3').Range¶ objRange.Text = '" & Quotes::AddressL3 & "'¶ Set objRange = objDoc.Bookmarks('QuoteAddress4').Range¶ objRange.Text = '" & Quotes::AddressL4 & "'¶ Set objRange = objDoc.Bookmarks('QuoteAddress5').Range¶ Set objRange = objDoc.Bookmarks('QuoteAddress5').Range¶ objRange.Text = '" & Quotes::AddressL5 & "'¶ Set objRange = objDoc.Bookmarks('QuoteName').Range¶ objRange.Text = '" & Quotes::QuoteContact & "'¶ Set objRange = objDoc.Bookmarks('Text1').Range¶ objRange.Text = '" &" " & Quotes::QuoteContact & "'¶ Set objRange = objDoc.Bookmarks('QuoteWeeks').Range¶ objRange.Text = '" & Quotes::Weeks & "'¶ Set objRange = objDoc.Bookmarks('SalesPerson').Range¶ objRange.Text = '" & $SP & "'¶ Set objRange = objDoc.Bookmarks('Position').Range¶ objRange.Text = '" & $Position & "'¶ objDoc.SaveAs('" & $WordFilePath & "')¶" ] #Replace all single quotes with double quotes so that script executes under Windows Set Field [ Quotes::VBscript ; Substitute ( Quotes::VBscript; "'"; """ ) ] #Save VBScript and open it (automatically open must be checked, to open it (execute it) following its generation) Export Field Contents [ Quotes::VBscript ; “$VBSFilePath”; Automatically open ] Set Variable [ $QName ; Value:Quotes::Client & " - Quotation " & Quotes::Quote No & "-" & Quotes::Doc Num ] Set Variable [ $QNum ; Value:Quotes::Quote No ] Set Variable [ $QClientID ; Value:Quotes::Client ID ] Set Variable [ $QType ; Value:"MS Word" ] Set Variable [ $QTypePDF ; Value:"PDF" ] Set Variable [ $QProjectID ; Value:Quotes::ProjectID ] Set Variable [ $WordFilePathToStore ; Value:"192.168.21.1CompanyDernier & Hamlyn Sales DocumentationQuotationsWord/Quotation " & Quotes::Quote No & "-" & Quotes::Doc Num &".doc" ] Set Variable [ $PDFFilePathToStore ; Value:"192.168.21.1CompanyDernier & Hamlyn Sales Documentation/Quotations/PDF/Quotation " & Quotes::Quote No & "-" & Quotes::Doc Num &".pdf" ] Go to Layout [ “L46 - Insert Quote Documents - Desktop” (Documentation) ] New Record/Request Set Field [ Documentation::Document No ; $QNum ] Set Field [ Documentation::ProjectID ; $QProjectID ] Set Field [ Documentation::ClientID ; $QClientID ] Set Field [ Documentation::DocumentName ; $QName ] Set Field [ Documentation::DocumentType ; "Quotation" ] Set Field [ Documentation::DocumentFormat ; $QType ] Set Field [ Documentation::DocumentFileName ; $WordFilePathToStore ] New Record/Request Set Field [ Documentation::Document No ; $QNum ] Set Field [ Documentation::ProjectID ; $QProjectID ] Set Field [ Documentation::ClientID ; $QClientID ] Set Field [ Documentation::DocumentType ; "Quotation" ] Set Field [ Documentation::DocumentName ; $QName ] Set Field [ Documentation::DocumentFormat ; $QTypePDF ] Set Field [ Documentation::DocumentFileName ; $PDFFilePathToStore ] Go to Layout [ original layout ] Show/Hide Toolbars [ Hide ] Set Variable [ $Path2; Value:"file://192.168.21.1/CompanyDernier & Hamlyn Sales DocumentationQuotationsWord/Quotation " & Quotes::Quote No & "-" & Quotes::Doc Num &".doc" ] Set Variable [ $file ; Value:"file:" & $WordFilePath ] End If Regards, Mark.
  9. randlem

    Open MS Word Document Using a VBScript

    Here Goes: "Set objWord = CreateObject('Word.Application')¶ objWord.Application.Visible = True¶ Set objDoc = objWord.Documents.Open( '///192.168.21.1/CompanyDernier & Hamlyn Sales DocumentationTemplatesquotation template.doc',,True)¶ Set objRange = objDoc.Bookmarks('QuoteDate').Range¶ objRange.Text = '" & Quotes::FormatDate & "'¶ Set objRange = objDoc.Bookmarks('QuoteRef').Range¶ objRange.Text = '" & $QuoteRef &"' ¶ Set objRange = objDoc.Bookmarks('QuotePhone').Range¶ objRange.Text = '" &" " & Quotes::QuotelPhone & "'¶ Set objRange = objDoc.Bookmarks('QuoteClient').Range¶ objRange.Text = '" &Quotes::Client & "'¶ Set objRange = objDoc.Bookmarks('QuoteAddress').Range¶ objRange.Text = '" & Quotes::QuoteAddress1 & "'¶ Set objRange = objDoc.Bookmarks('QuoteAddress2').Range¶ objRange.Text = '" & Quotes::AddressL2 & "'¶ Set objRange = objDoc.Bookmarks('QuoteAddress3').Range¶ objRange.Text = '" & Quotes::AddressL3 & "'¶ Set objRange = objDoc.Bookmarks('QuoteAddress4').Range¶ objRange.Text = '" & Quotes::AddressL4 & "'¶ Set objRange = objDoc.Bookmarks('QuoteAddress5').Range¶ objRange.Text = '" & Quotes::AddressL5 & "'¶ Set objRange = objDoc.Bookmarks('QuoteName').Range¶ objRange.Text = '" & Quotes::QuoteContact & "'¶ Set objRange = objDoc.Bookmarks('Text1').Range¶ objRange.Text = '" &" " & Quotes::QuoteContact & "'¶ Set objRange = objDoc.Bookmarks('QuoteWeeks').Range¶ objRange.Text = '" & Quotes::Weeks & "'¶ Set objRange = objDoc.Bookmarks('SalesPerson').Range¶ objRange.Text = '" & $SP & "'¶ Set objRange = objDoc.Bookmarks('Position').Range¶ objRange.Text = '" & $Position & "'¶ objDoc.SaveAs('" & $WordFilePath & "')¶" Regards, Mark
  10. randlem

    Open MS Word Document Using a VBScript

    Hi John, Thanks John for your response. No difference, just sits in the Taskbar and flashes when the bookmarks are populated and the document is being saved with a different name. I am wondering if there is a possibility that the problem could be the combination of Win 8.1 & Word 2010. Regards, Mark.
  11. randlem

    Open MS Word Document Using a VBScript

    Hi Singo, Sorry for the delay in getting back to you. I hadn't checked the forum as I was quite happy with the solution. When the script is being run over the vpn I have to change the pause to 25s. So any code the you can suggest to open the Word Doc in the foreground without having to close and re-open would be greatly appreciated. Kind regards, Mark.
  12. randlem

    Radio Button Set

    I have found what my problem was: I was using RightValues( Self ; 1 ) to input the radio set button value which causes a carriage return to be added to the end of the value. I found out that by using GetValue( Self ; ValueCount( Self ) ) stops the carriage return being added to the end of the value. I have tested and it works with my original calculation. Regards, Mark.
  13. randlem

    Radio Button Set

    Many thanks for your response. I changed the calculation to use IF PatternCount >0 then 1 else 0, which works. Regards, Mark.
  14. Hi There, I need some help with performing a calculation on a field in a table based on the contents of another field in the same table. The field I want base my calculation on is call Status whose content comes from a radio button set in a layout. The radio button set has three options Outstanding, Won and Lost. So I created a field called Outstanding set Type to Calculation and inserted the calculation: Case(Status = "Outstanding";1;0). When I display the field in a report all the rows show the value as 0 when at least 50% of the should display 1 and the Status field displays one of the three options. Then when I modified the calculation to use a different field (Sales Person) with a value of "JQ" it works as expected. So my question is when performing the calculation based on a Radio Button Set do you have to base it on the Option Number and not the value. I hope this makes sense. Kind regards, Mark.
  15. Many thanks Rgordon. Worked a treat. Regards, Mark.
×

Important Information

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