Experts,
I have the below code to save a workbook in PDF to the user's desktop with a file name from a cell value. When I send this workbook to a coworker, the code crashes, saying "Compile Error: Can not find project or library." Yet, the code works fine on my machine. I have had the user install the "ExceltoPDF" addin from Micrsoft and also uncheck the "Rely on system fonts only; do not use document fonts" setting on Adobe PDF. Can anyone please tell me how to fix this? Thanks.
Sub PrintPages() ' This macro prints designated sheets that have a value in cell N1 (Page #). ' This speeds up the macro. Application.ScreenUpdating = False Application.EnableEvents = False Application.DisplayAlerts = False Application.Calculation = xlCalculationManual ' This hides some sheets that we do not want to print. For Each wsh In ActiveWorkbook.Sheets If wsh.Range("M1") = "" Then wsh.Visible = xlSheetVeryHidden Next wsh ' This hides other sheets we do not want to print. Sheets("QAT").Visible = xlSheetVeryHidden Sheets("TAN").Visible = xlSheetVeryHidden Sheets("USH").Visible = xlSheetVeryHidden Sheets("CUR").Visible = xlSheetVeryHidden Sheets("Tables").Visible = xlSheetVeryHidden ' This prints the remaining unhidden sheets to the users desktop and names the file based on cell C2 in the Tables tab. With ActiveWorkbook .ExportAsFixedFormat _ Type:=xlTypePDF, _ Filename:=CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\" & Range("Tables!C2").Text & ".pdf", _ OpenAfterPublish:=False End With ' This makes the sheets we hid visible again. Sheets("TER Summary").Visible = True Sheets("Week 1").Visible = True Sheets("Week 2").Visible = True Sheets("Week 3").Visible = True Sheets("Week 4").Visible = True Sheets("QAT").Visible = True Sheets("TAN").Visible = True Sheets("USH").Visible = True Sheets("CUR").Visible = True Sheets("Tables").Visible = True ' This puts the cursor back to the Week 1 Tab. Sheets("Week 1").Select Range("F2").Select ' This resets the settings we changed to speed up the macro. Application.ScreenUpdating = True Application.EnableEvents = True Application.DisplayAlerts = True Application.Calculation = xlAutomatic End Sub
Last edited by wealthistime; 03-28-2011 at 10:07 AM. Reason: Solved
Open the workbook on the user's machine, open the VB EDitor and check under Tools-References for anything listed as 'MISSING:'
Woops, simple mistake. I forgot the DIM argument at the top. Problem solved! Thanks
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks