kudrow Posted September 30, 2014 Share Posted September 30, 2014 Hello Everyone, I searched around on the forums but I am not sure I am searching the right words to find what I am looking for. So I will just explain what I am trying to do and hopefully someone will point me in the right direction. Basically I have an excel spread sheet with data in it that I would like to auto-fill "place holders" with on a word template. So for each cell on row 1, there is a matching place holder in the template that will be replaced with the data from the cell. Once the placement is done I can save as a pdf. Anyone have any thoughts? Thanks! Link to comment Share on other sites More sharing options...
kudrow Posted October 1, 2014 Author Share Posted October 1, 2014 Well I am trying a few things out to see if I can make some progress. Currently I am reading in an .rtf and using StringReplace to change values on placeholders. The problem is the change is not saved with FileWrite and the FileClose. I do know the placeholder that I want to replace exists by checking it with StringRegExp. Below is my code, what am I missing? Local $file = FileOpen("pwf.rtf", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $filetoread = FileRead($file) $replace = StringReplace ($filetoread, "id_1", "My Text") FileWrite ($file, $replace) FileClose($file) Link to comment Share on other sites More sharing options...
water Posted October 1, 2014 Share Posted October 1, 2014 Word allows to merge data from a database (yes, Excel can act as a database) into a document. This could then be exported as PDF. I have never used it myself but when you search the forum for "mailmerge" you will get some hits. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
kudrow Posted October 1, 2014 Author Share Posted October 1, 2014 Thank you for the info. I am trying to avoid actually opening any other programs during the process. Is there anything wrong with my code above? Link to comment Share on other sites More sharing options...
water Posted October 1, 2014 Share Posted October 1, 2014 The error is caused by this line: FileOpen("pwf.rtf", 0) This opens the file in read mode. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
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