Results 1 to 1 of 1

ActiveSheet.Name not working?

Threaded View

  1. #1
    Registered User
    Join Date
    01-05-2012
    Location
    Salinas
    MS-Off Ver
    Excel 2007
    Posts
    22

    ActiveSheet.Name not working?

    I have set up a macro to print to PDF all sheets within a workbook (thanks to some input from this forum). It works on some workbooks, but tried running the macro today, and I got a message box that called the activesheet "working ", but not by the actual worksheet name. When I clicked "ok" to shut down the msgbox, I got a Run-time error '5', Invalid procedure call or argument.. Here is the code:
    Sub SavePDFAllWorkSheet()
    '
    ' SavePDFAllWorkSheet Macro
    '
    
     Dim APath As String
     Dim s As Long
     Dim ASName As String
     
     
     APath = ActiveWorkbook.Path & "\"
    
     MsgBox APath
     
     For s = 1 To Sheets.Count
        Sheets(s).Activate
        
        ASName = ActiveSheet.Name
        
    ' this is where it said "Working" in the MsgBox
    
        MsgBox ASName
        
        ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
            APath & ASName, Quality:= _
            xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
            OpenAfterPublish:=False
    
    Next
     
     
    End Sub
    Last edited by JosephP; 10-29-2012 at 05:32 PM. Reason: PLEASE use code tags ;-)

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