Consulting

Results 1 to 19 of 19

Thread: New error in previously working VB code

  1. #1
    VBAX Regular
    Joined
    Dec 2014
    Posts
    53
    Location

    New error in previously working VB code

    Hello,
    I'm using MS Office 2010 and I don't know if this is the correct location for this post. Thanks in advance for any help.

    Up until around Thanksgiving 2014 this code worked fine. Now it gives an error message when I run it. I am using a macro button to run a piece of code (see attached) that exports all sheets of the tab (except the current one) to a PDF file and it names each file with the same name as the sheet name. I have about 20 sheets and each saves to a PDF file.

    The first attachment below shows the code and the highlighted piece is where the error apparently lies. The second attachment shows the error message. I am not a programmer.

    I've copied the code from a helpful website and it is exactly as it was given to me. I've heard that in December 2014 Microsoft rolled out an update to all users which protects against a remote user access problem and that update may be causing this issue. I've already had my IT dept follow the suggested steps to delete all of the .exd files. The problem persists. Can anyone help me fix this issue? Im on the verge of rolling this dashboard out to about 100 users and Ive got to be able to export to PDF in one click. Thanks again for any help
    Attached Images Attached Images

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    Not absolutely sure but if you follow this link it may help your IT department overcome the issue. Seems a recent update released by Microsoft may be responsible.http://excelmatters.com/2014/12/10/o...ivex-controls/
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  3. #3
    VBAX Contributor
    Joined
    May 2010
    Location
    Sydney, NSW, Australia
    Posts
    170
    Location
    The code is correct, maybe a dead reference?

    Click Debug on that window then in the window that opens up click the Stop button (looks like a square) then click tools / references

    All the ones that are ticked (they will all be at the top) do any of them say "Missing"?

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    MS has been issuing Updates that break various Office components.

    They don't effect the existing code, they effect applications like MS Forms and MS Excel that use the code.

    IIRC, one was issued Dec14 and another in very early 2015
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  5. #5
    VBAX Regular
    Joined
    Dec 2014
    Posts
    53
    Location
    Thanks for the help Blade Hunter. I've inserted an image of the reference section but I don't see anything missing
    Attached Images Attached Images

  6. #6
    VBAX Regular
    Joined
    Dec 2014
    Posts
    53
    Location
    Thanks Aussiebear, they've already followed the link, deleted all of the .exd files and the problem persists

  7. #7
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    Can you run the code by clicking within it in the VBE and then pressing f5?
    Be as you wish to seem

  8. #8
    VBAX Regular
    Joined
    Dec 2014
    Posts
    53
    Location
    Aflatoon, this is what I get when I open the VB editor, click on module 3, and hit F5
    VBE screen 1.jpgVBE screen.jpg

    These look small but can you see them? What does this mean?

  9. #9
    VBAX Contributor
    Joined
    May 2010
    Location
    Sydney, NSW, Australia
    Posts
    170
    Location
    When you are in the VBE press CTRL-G to bring up the immediate window.

    Paste this in the window that appears:

    activeworkbook.exportasfixedformat type:=xltypepdf, filename:="V:\Arizona CSRs\Dashboard\Team PDFs\Phoenix\" & activesheet.name & ".pdf", Quality:=xlqualitystandard, includedocproperties:=true, ignoreprintareas:=false, openafterpublish:=false
    then press enter

    see if the file is created.

    Also, does the file already exist there?

    Also what is the name of the sheet it is trying to export? It may have a reserved character in it.

  10. #10
    VBAX Regular
    Joined
    Dec 2014
    Posts
    53
    Location
    Blade
    See if what file is created? Do you mean, does it correctly execute each tab into a PDF? If so, then it doesn't. The immediate window was empty when I hit Ctrl G.

    Also, does the file already exist there? Not sure what you mean here

    Also what is the name of the sheet it is trying to export? It may have a reserved character in it. It is exporting all sheets except the one called "welcome screen". I've attached a screenshot of all the sheet tab names. Do you want to look at the actual excel sheet? I can upload or email if it helps
    Attached Images Attached Images

  11. #11
    VBAX Contributor
    Joined
    May 2010
    Location
    Sydney, NSW, Australia
    Posts
    170
    Location
    Does this file exist:

    V:\Arizona CSRs\Dashboard\Team PDFs\Phoenix\activesheet.name.pdf

    Where activesheet.name is the name of the sheet you are exporting

    See if what file is created?

    That line of code I posted and told you to run in the immediate window (CTRL-G) should create a file in the correct folder with the same name as the active sheet.

  12. #12
    VBAX Regular
    Joined
    Dec 2014
    Posts
    53
    Location
    These are examples of what it should create but it does not:

    V:\Arizona CSRs\Dashboard\Team PDFs\Phoenix\David.pdf
    V:\Arizona CSRs\Dashboard\Team PDFs\Phoenix\Amy.pdf
    V:\Arizona CSRs\Dashboard\Team PDFs\Phoenix\Danielle.pdf

    It should create 27 PDFs, one for each tab except the "welcome screen" tab

    The code used to save each workbook tab as a PDF with the name of the sheet tab as the file name

    See if what file is created?

    That line of code I posted and told you to run in the immediate window (CTRL-G) should create a file in the correct folder with the same name as the active sheet

    I keyed that piece of code in the immediate window but its not there now and not in the "welcome screen" tab either. What now? Thanks for your help

  13. #13
    VBAX Contributor
    Joined
    May 2010
    Location
    Sydney, NSW, Australia
    Posts
    170
    Location
    Put it in the immediate window again, hit enter then look for the file.

  14. #14
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    You need to click somewhere in the code itself and then press f5.
    Be as you wish to seem

  15. #15
    VBAX Regular
    Joined
    Dec 2014
    Posts
    53
    Location
    I didn't understand what you meant before but now I get it. When I enter the text in the immediate field and hit enter, it creates a PDF in the designated location. It is one large PDF (1,092kb) with all of the worksheet tabs displayed one after the other. What now?

  16. #16
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location


    Humor me and replace those three lines with
    Sht.exportasfixedformat type:=xltypepdf, filename:=MyPath & FileName
    And if that doesn't change the situation, restore them with
    Sht.exportasfixedformat type:=xltypepdf, filename:=MyPath & FileName, _
      Quality:=xlqualitystandard, includedocproperties:=true, _
      ignoreprintareas:=false, openafterpublish:=false
    It is really poor form to interrupt an argument.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  17. #17
    VBAX Regular
    Joined
    Dec 2014
    Posts
    53
    Location
    I am not a programmer.

    So I tried both methods. The first didn't work and the second generated a sheet called "welcome screen" with only the contents of that screen and then crashed with the same error as before

    error%20message.png

  18. #18
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    By "Three lines" I meant the three yellow lines
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  19. #19
    VBAX Regular
    Joined
    Dec 2014
    Posts
    53
    Location
    Yes that is what I did and the results are above

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •