![]() i am getting an error called 4168 command failed/command execution on this line: DataType:wdPasteText. Its so common that almost everyone knows. Bookmarks("heatlosses").Range.Text = Range("B19").CurrentRegionĪll this does is paste the word "True" into Word. when this formula yields NOTHING or a blank, and i run my macro, i get an error on PASTING this into word. Copying and pasting is a very frequently performed action when working on a computer. If I try and copy/paste a range, instead of just one value, I was using Currentregion to select all used cells surrounding B19: With objWord.ActiveDocument I'm trying to tackle this one step at a time, cos then I have half a chance of understanding things a bit better. Bookmarks("heatlosses").Range.Text = ws.Range("I19").Value 'pastes the value of cell I19 at the "heatlosses" bookmark "K:\Exeter Office\Quotebuilder project\testbed\test.docx" 'change as required Set objWord = CreateObject("Word.Application") ![]() I can't find a neat bit of code that allows me to paste data into an already-open document.Īlso, I can make this work for one value, but not for a range (i.e. 190, 196 documents formatting Excel data in, 736 Word, copying Excel charts to. If I try to run this sub when the word doc is open, it just tries to re-open it and of course can't. Group, 441 Insert Function, 169 Insert menu, 58 Macro Options. The below code works, but I can only get it to work when the Word document in question is closed. I'm trying to automate the creation of a document as much as possible. I have seen this done using a keyword search but I would prefer to use a bookmark (and I've made the bookmark thing work!) purely because it's not visible to the end user. 'NOTE: Must have Word Object Library Active in Order to Run. Sub ExcelRangeToWord () 'PURPOSE: Copy/Paste An Excel Table Into a New Word Document. What I want is to copy a (admittedly large) table in a specific Excel worksheet into an already-open Word document, at a specific point. Right below the VBA code I will provide a little more detail on what the macro routine is doing so you can fully understand its makeup. I know this is user error - I am learning/self-taught at this. I have searched a fair bit on this and other forums but I can't get code to work.
0 Comments
Leave a Reply. |