+ Reply to Thread
Results 1 to 16 of 16

export a range and save as .jpg

Hybrid View

  1. #1
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,983

    Re: export a range and save as .jpg

    Change this line in the JPG_Snapshot routine:
     MyAddress = SelectArea
    to:
     MyAddress = "A1:C5"
    for example.
    Everyone who confuses correlation and causation ends up dead.

  2. #2
    Forum Contributor
    Join Date
    01-23-2010
    Location
    Suffolk, England
    MS-Off Ver
    Office 365
    Posts
    271

    Re: export a range and save as .jpg

    Hi,

    Again, fantastic this works perfectly

    Is it possible to turn the grid off for the picture only?

    Thanks

  3. #3
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,983

    Re: export a range and save as .jpg

    Turn it off at the start and back on at the end:
    Public Sub JPG_Snapshot()
        Dim varReturn As Variant
        Dim MyAddress As String
        Dim SaveName As Variant
        Dim MySuggest As String
        Dim Hi As Integer
        Dim Wi As Integer
        Dim wks As Worksheet
        
        Set Sourcebook = ActiveWorkbook
        Activewindow.DisplayGridlines = False
        Set wks = ActiveSheet
        Set containerbook = Workbooks.Add(1)
        containerbook.Sheets(1).Name = "JPGcontainer"
        MySuggest = sShortname(wks.Name)
        Set container = CreateContainer(containerbook)
        Sourcebook.Activate
        MyAddress = SelectArea
        If MyAddress <> "A1" Then
            SaveName = "C:\Users\Stephen\Documents\Marshall\PDD Macro Test " & Format(Date, "m-d-yyyy") & ".jpg"
            If SaveName <> False Then
                With wks.Range(MyAddress)
                    .CopyPicture Appearance:=xlScreen, Format:=xlBitmap
                    Hi = .Height + 4  'adjustment for gridlines
                    Wi = .Width + 6   'adjustment for gridlines
                End With
                MakeAndSizeChart container, ih:=Hi, iv:=Wi
                With container
                    .Paste
                    .Export Filename:=LCase(SaveName), FilterName:="jpg"
                    .Pictures(1).Delete
                End With
                Sourcebook.Activate
                Activewindow.DisplayGridlines = True
            End If
        End If
    
        On Error Resume Next
        Application.StatusBar = False
        containerbook.Saved = True
        containerbook.Close
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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