+ Reply to Thread
Results 1 to 5 of 5

Exporting selected data from Excel to Word

Hybrid View

  1. #1
    Registered User
    Join Date
    05-27-2013
    Location
    Middle, Nowhere
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Exporting selected data from Excel to Word

    Sure! I've attached them as follows. And yes, it would be preferable if the Word Document could remain editable.

    Basically the macro I'm trying to get the macro to fill in the student number and name on the world document using the appropriate cells in excel. Ideally then it would select all the courses that particular student took and paste that into the word document with the appropriate grades and numbered accordingly as shown in the word document. [This is the complicated part given that every student takes a different number of courses.] The macro would then save as the student number and close. I have somewhat managed the front portion of this with this macro I pieced together which doesn't use bookmarks:

    Sub ControlWord()
    
        Dim appWD As Word.Application
        Dim Name As String
        Set appWD = CreateObject("Word.Application")
        appWD.Visible = False
    
        Sheets("Sheet1").Select
        FinalRow = Range("A9999").End(xlUp).Row
        For i = 2 To FinalRow
            Sheets("Sheet1").Select
           
            Range("B" & i).copy Destination:=Sheets("Sheet2").Range("B1:C1")
            Range("A" & i).copy Destination:=Sheets("Sheet2").Range("B2:C2")
            
            Range("A4:G37").copy 
            appWD.Documents.Add       
            appWD.Selection.Paste
            
            
            Name = Sheets(1).Cells(i, 1).Value
            appWD.ActiveDocument.SaveAs filename:= Name
          
            appWD.ActiveDocument.Close
            
        Next i
     
        appWD.Quit
    
    End Sub
    I know it's not a very elegant way of doing this and it does cause problems. Using the macro to paste from excel into word makes the entire table longer than one page. I don't encounter this problem while manually copying and pasting. Terribly long wall of text but thanks for reading through! I'm happy to explore other methods.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1