0

I am trying to save a single worksheet from a workbook into a location of the user's choice. The worksheet I want to save has images that change depending on values from another worksheet inside the workbook. My code looks something like this

Sub SaveWorksheet()

    blah = Val(Sheet1.ComboBox1)

    if blah = (number) then

        Sheet4.Image1.Picture = LoadPicture("reference.jpg"

    end if 

    **Filename = Application.GetSaveAsFilename
    Application.Worksheets.Application.SaveWorkspace (Filename)**

End Sub

What I have saves the whole workbook into the location of choice, but I just want Sheet4 to be saved as a pdf to another location.

Community
  • 1
  • 1
user3481875
  • 43
  • 12
  • 1
    Perhaps [this](http://stackoverflow.com/questions/20750854/excel-vba-to-export-selected-sheets-to-pdf) or [this](http://answers.microsoft.com/en-us/office/forum/office_2010-excel/export-worksheet-to-pdf-using-vba/bc63bd6f-665c-e011-8dfc-68b599b31bf5) – Tanner Jun 27 '14 at 15:38
  • You probably want to PRINT that sheet as a pdf. I use CutePDF Writer (Excel 2003). – dcromley Jun 27 '14 at 15:43
  • 1
    @tannman357 that does look like a good answer. It has not been "accepted" so I can't mark this one as a duplicate. Feel free to answer *this* question using that method. :) – David Zemens Jun 27 '14 at 15:47

1 Answers1

0

Like I put in the comments, there is an answer to this question here. I will repeat the answer here, since it hadn't been accepted in the other question, like Zemens suggests.

Once you have Selected a group of sheets, you can use Selection

Consider:

Sub luxation()
    ThisWorkbook.Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
    Selection.ExportAsFixedFormat _
        Type:=xlTypePDF, _
        Filename:="C:\TestFolder\temp.pdf", _
        Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, _
        IgnorePrintAreas:=False, _
        OpenAfterPublish:=True
End Sub
Community
  • 1
  • 1
Tanner
  • 548
  • 8
  • 20