- #Delphi insert into word document at cursor code#
- #Delphi insert into word document at cursor series#
- #Delphi insert into word document at cursor windows#
#Delphi insert into word document at cursor windows#
#Delphi insert into word document at cursor code#
A source code to HTML syntax-highlighter.My first experience with the Delphi 2009 Translation Tool.Word.Range rngInsertNew = document.Content This would mean that you need a Range starting point going into the loop.
An alternative would be to re-assign the Range starting point to the last Range you've inserted, which would be pPicture.Range. One possible solution would be to simply reverse your loop: for (var i=10 i>0 i-) If you think about it, it's logical that, given a Range point at the beginning of the document anything you insert will always go in at the beginning. I've deleted the duplicate post that was moved here from the other forum as it didn't contain any useful discussion - just FYI in case you go looking for it or get an alert. Var pPicture = () ĭ(Path.Combine(Environment.GetFolderPath(), "img_1.png"), Range: pPicture.Range) Ĭan anyone provide me a solution to move the cursor to top of document and insert my new content from there. at the top/starting of document and then insert the content one below the another through Before going into this for loop, I want my cursor/insertion point to be positioned So my loop will decide what is the current iteration and will insert a paragraph I'm looping through a List of strings which contains either text or path of the image. What I haven't tried is using the praragraphs.range yet.īTW this is the code that I'm using to insert my new content Piece of content goes to the last and the second one goes previous to the last and so on until the last content becomes the first. The new content gets inserted upside down in the order of insertion. Now the content gets inserted to the beginning but there is a little problem in that insertion. I've created a range object and set its start and end refereces to 0 and 0. Now I'm able to move the cursor to beginning of doucment. Then I got advice to select the range of entire document and try to insert the new content Word.Range rng I've also tried the combination of object units =
#Delphi insert into word document at cursor series#
The document which I want my new content to be inserted already contain a series of text and images. WordApp.Quit(ref oMissing, ref oMissing, ref oMissing) Object savePath = path + + fileName + ".doc" Path += docDir = new DirectoryInfo(path) Var pImage = (ref oMissing) ĭoc.InlineShapes.AddPicture(image, ref myFalse, ref myTrue, ref myRng) Object which = ĭoc.GoTo(ref what, ref which, ref oMissing, ref oMissing) String images = Directory.GetFiles(path) Object filePath = originalPath + + doc = (ref filePath, Word._Application wordApp = new Word.Application() String originalPath = Directory.GetCurrentDirectory() Public void CreateWordDocument(string fileName) What I've done so far, but always the content gets appended at the end. That is I want the new content to appear at the top. I'm able to create new document, but I also want to open an existing document and add the content to it from the beginning. Sorry for double post.Īs the title suggest, I'm trying to create word document through C#. I've originally posted the thread to C# general and was asked to post into Word Dev Forum.