+ Reply to Thread
Results 1 to 6 of 6

Print PDF error message

  1. #1
    Registered User
    Join Date
    11-12-2018
    Location
    Cornwall, England
    MS-Off Ver
    Excel 2016 (Office 365 ProPlus)
    Posts
    58

    Lightbulb Print PDF error message

    Hopefully a simple one! I have been using the below macro successfully to print sheets to PDF. However if a user has not selected anything from the list box the macro will fail at the point shown below in red.

    I am looking for a way to add a message box prompt the user if this happens and to direct them to ''first select at least one sheet from the list box''. I have tried a few ways that I know and its not working, so thought I would turn to some experts for a quick solution. Thanks!!

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,474

    Re: Print PDF error message

    Possibly check if nothing is selected?

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-12-2018
    Location
    Cornwall, England
    MS-Off Ver
    Excel 2016 (Office 365 ProPlus)
    Posts
    58

    Re: Print PDF error message

    Thank you - thought your suggestion would work perfectly but for some reason it fails on the below line stating.... Run-time error '438' Object doesn't support this property or method.

    Please Login or Register  to view this content.
    I have also incldued my list box code incase this is could be to blame.

    Please Login or Register  to view this content.

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,474

    Re: Print PDF error message

    Ah,
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-12-2018
    Location
    Cornwall, England
    MS-Off Ver
    Excel 2016 (Office 365 ProPlus)
    Posts
    58

    Re: Print PDF error message

    OK cheers....this now runs, but not achieving the desired result. Reading around I found an article that states "ListIndex doesn't really work with multiselect listboxes and ListCount will tell you the no of items in the listbox. To check if nothing has been selected in a multiselect listbox you need to loop through the list."

    So have used the below code. Think this is almost there - but for some reason it now always displays the msg box saying 'nothing selected' even when something is!?!

    Please Login or Register  to view this content.
    Last edited by mattydboom1; 09-14-2020 at 03:07 PM.

  6. #6
    Registered User
    Join Date
    11-12-2018
    Location
    Cornwall, England
    MS-Off Ver
    Excel 2016 (Office 365 ProPlus)
    Posts
    58

    Re: Print PDF error message

    OK finally got there I think. The 'And' should have been an 'Or'


    Please Login or Register  to view this content.
    Last edited by mattydboom1; 09-14-2020 at 03:06 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] On error print message and stop execution of subsequent subrotine
    By jakopak in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-27-2015, 06:55 PM
  2. Microsoft Visual Basic error message when trying to print Excel user form
    By cpieramico in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-13-2015, 04:22 PM
  3. An error message on open - a totally blank VBA message box
    By Mr_Tigas in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-05-2013, 11:29 AM
  4. Print preview error message
    By bullwinkle in forum Excel General
    Replies: 1
    Last Post: 07-19-2007, 04:44 PM
  5. [SOLVED] replace VBA run-time error message with custom message
    By BEEJAY in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-14-2006, 11:05 AM
  6. [SOLVED] How to print when an error message keeps showing?
    By clueless in forum Excel General
    Replies: 1
    Last Post: 01-30-2006, 01:40 PM

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