How to deal with single quote in Word VBA SQL query?
Where you specify two single quotes ”, one will escape the other and will result in single, try to replace it like this: customerName = Replace(customerName, “‘”, “””)
Where you specify two single quotes ”, one will escape the other and will result in single, try to replace it like this: customerName = Replace(customerName, “‘”, “””)
If your goal is to perform replacements in the whole documents (it looks so from the code, but it is not explicit), I would suggest you use Document.Range instead of the Selection object. Using Document.Range will make sure everything is replaced, even inside tables. Also, it is more transparent to the user, as the cursor … Read more
Leave the parameter value as a missing value for the Row.Add Function object oMissing = System.Reflection.Missing.Value; // get your table or create a new one like this // you can start with two rows. Microsoft.Office.Interop.Word.Table myTable = oWordDoc.Add(myRange, 2,numberOfColumns) int rowCount = 2; //add a row for each item in a collection. foreach( string s … Read more
Here is the simple Demo App , you can modify it for button click event : import java.awt.Desktop; import java.io.File; import java.io.IOException; public class Test { public static void main(String[] a) { try { if (Desktop.isDesktopSupported()) { Desktop.getDesktop().open(new File(“c:\\a.doc”)); } } catch (IOException ioe) { ioe.printStackTrace(); } } } This would open word file with … Read more
Do you know about the Office Web Apps? Microsoft developed something similar to Google Docs and you can use the Word Web Application to view Word files. It will pretty much display anything – a lot of editing functions from the offline version are not available though. If you are just looking for a viewer … Read more
I use this function to find and replace. you can specify any of the options. private void FindAndReplace(Microsoft.Office.Interop.Word.Application doc, object findText, object replaceWithText) { //options object matchCase = false; object matchWholeWord = true; object matchWildCards = false; object matchSoundsLike = false; object matchAllWordForms = false; object forward = true; object format = false; object matchKashida … Read more
Everthing should work fine if you don’t use a low-level hook in your VSTO add-in. [DllImport(“kernel32”, CharSet = CharSet.Auto, SetLastError = true)] public static extern int GetCurrentThreadId(); const int WH_KEYBOARD = 2; private static IntPtr SetHook(HookProcedure procedure) { var threadId = (uint)SafeNativeMethods.GetCurrentThreadId(); return SetWindowsHookEx(WH_KEYBOARD, procedure, IntPtr.Zero, threadId); } Please note that you probably also need … Read more
Although the documentation for OpenXML isn’t great, there is an excellent tool that you can use to see how existing Word documents are built. If you install the OpenXml SDK it comes with the DocumentReflector.exe tool under the Open XML Format SDK\V2.0\tools directory. Images in Word documents consist of the image data and an ID … Read more
Try using pandoc pandoc -f html -t docx -o output.docx input.html If the input or output format is not specified explicitly, pandoc will attempt to guess it from the extensions of the input and output filenames. — pandoc manual So you can even use pandoc -o output.docx input.html
As has been noted, there don’t appear to be any libraries to manipulate Open XML documents in Ruby, but OpenXML Developer has complete documentation on the format of Open XML documents. If what you want is to send a copy of a standard document (like a form letter) customized for each user, it should be … Read more