Posts by thorn1979

    Re: Excel VBA to paste cells/table into an already-open Word doc

    okay, well the Word macro that calls everthing is this:

    I am sorry, I was just trying to keep things simple by doing it in stages.

    Yes, same document.. I am trying to automate as much of a process as possible. The idea is that the end user opens the word document (it's a quote), then can run a macro that will import some technical data and place it at a set point. Trouble is, that technical data varies for every project, which is why I was doing it this way around instead of just opening the Excel workbook to begin with, and then sending the relevant data to the Word document.

    Hi folks.

    I am sorry if I don't get this right, I'm new to forums and to VBA. I am very grateful for any help anybody can offer, so thank you for taking time to look over my problem. Working in Excel 2013.

    I have got a Word macro that opens a specific excel file, and then runs a macro in that file.

    It's the macro within Excel I am struggling with.

    What I want to do is copy a whole table from a worksheet and plonk it into the open word document at a given position (I was using a bookmark which I have called "heatlosses").

    I can make this work for the value of one cell, rather than a whole table - I was starting small! - but my code falls over when the Word document is already open. Which it would be, because of the way I am using the word document.

    So I have 3 issues...

    1) how can I make it work for an open word document, rather than trying to re-open it?
    2) how can I paste a whole table or range instead of one value? I tried using used.range...

    which leads me to
    3) the table is huge, I would love to paste it as a picture - is that possible?

    My code thus far is

    Re: Macro to open Word and Start Mail Merge

    Hi all.

    Hope you can help me, I am very new at this!

    I have an Excel workbook. I want to take certain values from said workbook and put them into a word document (basically Word outputs things more prettily!). I also need too make this as idiotproof as possible.. so my hope was to take the Excel document that I am using (I create a quote using it), and be able to hit a button which runs a macro that calls up the Word template I want to use, bungs everything into that, then gives the option to print it to pdf and then save that pdf.

    I've tried Ender's code first, which gets me as far as starting Word (good start), but won't run the mailmerge - I think because the data source I am trying to use is the Excel file I am already working in.

    Then tried Wendie's code.

    Again this starts Word, and then I get an Excel runtime error 4605 saying "This method pr property is not available because the current mailmerge main document needs a data source".

    Here's the chunk of Wendie's code it doesn't like:

    'Now you start opening the Word application and the document
    With wdApp

    ' Set wdDoc = .Documents.Open

    Set wdDoc = .Documents.Open(Filename:="K:\Projects\Quote Templates\selfbuild estimate template.docx") '<==this opens the document so you can manipulate it.
    wdDoc.Application.Visible = True

    ' Just telling word how to run the merge

    With wdDoc.mailmerge
    .MainDocumentType = wdFormLetters
    .Destination = wdSendToNewDocument
    .SuppressBlankLines = True
    .Execute Pause:=False

    End With

    .....and from there on.

    Why not just open the word file manually and merge from there? Because the person generating the quote will already be working with an excel file, and I need to generate 4 different kinds of quote depending on the type of customer. So it makes more sense to do it from Excel than from Word.

    I think basically I need to tell Word to use the open Excel workbook as the datasource... help... please!!