Results 1 to 3 of 3

Copy Excel range a number of sheets as pictures to MS Word, each picture on new Word page.

Threaded View

  1. #1
    Registered User
    Join Date
    03-14-2018
    Location
    Johannesburg
    MS-Off Ver
    Windows 7 MS Excel 2010
    Posts
    2

    Copy Excel range a number of sheets as pictures to MS Word, each picture on new Word page.

    Good day,

    I am busy with a major selection program which is excel base, however, I cannot seem to fix a small issue with one of my sub-routines. To explain what the sub-routine should do: an Excel workbook will have a number of sheets, each containing a range which is already set as the print area. I wrote VBA code for this print area range to be copied into a word document which works. I also wrote VBA code to loop through all sheets in the Workbook and copy the respective range to Word, which also works (the loop works, and each copy instance woks). Just to clarify, there are sheets that should not be copied - the sheets that contain the range that should be copied are identified by the program with a "2" in the first cell "A1" of the sheets where the range must be copied. Hence, the IF function in the FOR loop below.

    The problem is that each subsequent range is copied on top of one another at the start of the Word document, and in the end only one picture of the range is copied. The pictures should be copied inline beneath one another, maybe separated with a paragraph character. The code I have is as per below (I have removed all previous attempts made to fix this):
    Sub PastWord()
    
    Dim exlWB As Excel.Workbook
    Set exlWB = ActiveWorkbook
    Dim appWord As Word.Application
    Set appWord = New Word.Application
    appWord.Visible = True
    Dim Doc As Word.Document
    Set Doc = appWord.Documents.Add
    Doc.PageSetup.Orientation = wdOrientLandscape
    Doc.PageSetup.TopMargin = 3
    Doc.PageSetup.BottomMargin = 3
    Doc.PageSetup.RightMargin = 3
    Doc.PageSetup.LeftMargin = 3
    
    Dim PrtArRg As Range
    
    Dim nos As Integer  ' nos is Number of Sheets
    nos = exlWB.Sheets.Count
    
    Dim nosc As Integer ' nosc is Counter for For function
    
    For nosc = 1 To nos
        If exlWB.Sheets(nosc).Cells(1, 1) = 2 Then ' "2" indicates the sheets that contain the range to be copied
                 
                    
            Set PrtArRg = exlWB.Sheets(nosc).Range(ActiveSheet.PageSetup.PrintArea)
            PrtArRg.CopyPicture Appearance:=xlScreen, Format:=xlPicture
                
            Doc.Content.Paste
            
            Else
        End If
    Next nosc
        
    End Sub
    Last edited by IGTsmith; 03-14-2018 at 04:46 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA copy excel as a picture to word - zoom picture
    By michelle 1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-01-2016, 06:47 AM
  2. Inserting Picture into Picture Content Control in Word crashes Word
    By atycks in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-07-2015, 09:59 AM
  3. Copy Many Word Docs to New Word Doc (Each Word Doc Should be on New Page)
    By realniceguy5000 in forum Word Programming / VBA / Macros
    Replies: 3
    Last Post: 05-05-2013, 03:28 AM
  4. Copy and paste vba pictures from excel to word
    By mcaballero in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-19-2013, 03:54 PM
  5. VBA code to copy and create n number of word documents from excel range
    By skonduru in forum Word Programming / VBA / Macros
    Replies: 3
    Last Post: 01-17-2013, 03:20 PM
  6. [SOLVED] Copy excel range and paste special picture (metafile) into existing word dot VBA
    By Markcuss in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-06-2012, 08:21 PM
  7. Copy & Paste pictures from Excel into Header (and Footer) of Word
    By RogerPang in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-04-2012, 04:52 AM

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