Results 1 to 25 of 25

Thread: Adobe Acrobat 5.0

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Posts
    232

    Adobe Acrobat 5.0

    does anyone know if i can add a toolbar button in adobe acrobat?
    if so how can i do that through code?
    I need to write a simple plugin however i do not know C++ so i need to do it in javascript or vb.
    any help with this would be great.
    Thanks.

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    I don't think you can do this, but before giving up completely, you might want to check out the developer sdk's & tech support lines over at adobe.com first...

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    I have done some automation of Acrobat and I have found that
    the main, perhaps only, way to add a toolbar to Acrobat is to use
    C++. You can add menuitems easily using JavaScript, though.

    If you are just trying to control Acrobat then you may be able to
    get by with VB. Add a reference to "Adobe Acrobat 5.0 Type
    Library." You won't get all the toolbars and menus, but you can
    create your own, sort of Acrobat viewer.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Posts
    232
    Thanks for your response.
    I wrote some code in VB as you suggested and it worked. However when i try to put that code into ASP, the page freezes.
    What am I missing?? I starts freezing when i add the line
    VB Code:
    1. Set gApp = server.CreateObject("AcroExch.App")

    if you have any ideas i would appreciate it.
    Thanks

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Do you have Acrobat installed on your webserver?
    It needs to be, this could be the issue.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Posts
    232
    of course i have it installed.
    in fact i ran my vb program on my local machine - works fine. then i test it in the ASP page from localhost. Shouldnt it be able to access the same adobe??
    Thanks again.

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Can you give me a overview of what and how you are trying to
    accomplish? I just want to understand what you are trying to
    do so I can help better.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Posts
    232
    ok,
    I am trying to create a scanning project from the web. Meaning there will be an asp page with a button that says scan. I want that as soon as the person clicks scan the adobe scan dialogue box should appear and set a directory for the document to be scanned into.
    so far i wrote the following code:
    VB Code:
    1. Dim gApp As Acrobat.CAcroApp
    2.     Set gApp = CreateObject("AcroExch.App")
    3.     gApp.MenuItemExecute ("Scan")
    this works when run it from visual basic on my local machine. it briings up the scan dialogue box.
    so now firstly i need to get this code to work from asp.
    then i need to add funtionality (if possible) to make it set the directory.

    I hope this gave you some more of an understanding.
    I hope you will be able to help.
    Thanks.

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Could it be some type of permissions issue?

    Or the only other thing that I can think of is if it is waiting for
    Acrobat to finish loading and it tries to execute the scan menu
    before the app is done loading.

    Can you get it to do something else instead of the scan?

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Posts
    232
    Maybe it is a permission issue, I just have no idea what permission issue it could be, do you?
    As per the second thing you suggested, I think that is not so since the code already freezes when i just have the first 2 lines of code - initializing the variable and createobject acroexch.app.
    Thanks again for your help.

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Posts
    232
    I got a little further but I am still having problems with it.
    Now Here is my code:

    dim gApp
    Set gApp = server.CreateObject("AcroExch.App")
    gApp.Show
    gApp.MenuItemExecute("Scan")
    gApp.Exit
    set gApp = nothing

    It freezes out on gApp.MenuItemExecute("Scan")
    and then when i go to the task manager and it says i dont have access to kill adobe.exe so i need to kill it from the command.
    any ideas?
    thanks.

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    I remember that there is some kind of security or protection
    under Acrobat for when you want to automate it using JavaScript
    and menus from a web enviroment. Something about the
    document having to reside on the local machine in order to
    execute or add menuitems.

    Do you have any of the SDK documentation from Acrobat?
    I remember reading about it in there. There may be something
    similar when using vb.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Posts
    232
    but i am only trying to execute the menuitem not add a menuitem? what can be different from vb and asp?

  14. #14
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Can you test your code by changing the menuitem to execute?
    Also, it is true that the menuitems are not actually named as
    seen. So maybe you need to get the actual name of the "Scan"
    menuitem. This could be the freeze reason. Try changing it to
    something else simple. Give me a minute to retrieve thae actual
    name of the scan.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  15. #15
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    In Acrobats JavaScript console type this and press enter to list
    out the actual names of the menuitems in Acrobat.
    Code:
    app.listMenuItems();
    Where is the Scan menuitem?
    I don't have it in mine. Is it a plug-in that you have?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  16. #16
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Found some documentation at Adobe...


    How To: Automate Scanning

    Summary
    Adobe Acrobat offers no means of automatic document scanning and saving.

    Issue
    When trying to create an automatic document scanning and
    saving process that does not require user intervention, I call
    app.MenuItemExecute("Save"). This causes Adobe Acrobat to
    display the 'Save As' dialog. Is it possible to suppress displaying
    these response windows?

    Solution
    There are no Acrobat api's including the MenuItemExecute
    ("Scan") that will automate scanning and saving a document(s)
    without user input. There is no way to suppress nor pass
    keystrokes to the Scan or Save dialogs, which are a result of
    executing their menu items.


    Please note that Adobe Acrobat Capture works with the scanner
    to convert paper documents to pdf.
    http://www.adobe.com/products/acrcapture/main.html

    Don't know if this helps.

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Posts
    232
    Thank you for taking out your time for me. It is really appreicated. you definitely helped me somewhat.
    I got the scan part to work.
    what i did was i wrote is as a vbscript locally to the client so each client's personal adobe acrobat brings up the scan. I then scan in the document. my next question is. do you know how i can set the directory programmatically so that it will scan into a directory automatically. There is a setPreference method, is there a preference in adobe where to scan to??
    Thanks again.

  18. #18
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    You can write some JavaScript to hard code the path for saving
    files so I assume that you can do the same with the scan.

    What I have done was removed the "Save" menuitem and
    the "Save" toolbar button. Then I added a menuitem to "Save
    to...", for example, and I had JavaScript code to save the file to a
    particular directory.

    The JavaScript file needs to located in the directory of
    \Program Files\Adobe\Acrobat 5.0\Acrobat\Javascripts

    The only issue will be that the file will need to be on the client station.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  19. #19

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Posts
    232
    would you be able to give me some code snippet from that?

  20. #20
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Sure, give me some time to trim it down. I have allot of code that
    doesn't pertain to what you want to do. Remember that the code
    will need to be loaded on every workstation the will be using
    your app. Its client side processing.

    Hold on...
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  21. #21
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Here is some basic stuff you need. Platform detection and the
    removal of the save menu item and save toolbar button.

    If you want the code to execute for other versions like Reader
    then you need to add the file to the JavaScripts directory under
    \Program Files\Adobe\Acrobat 5.0\Reader\JavaScripts
    To reset your Acrobat back to its original look and feel, just
    rename the JavaScript file to a different extension and it wont be
    loaded at startup.

    Code:
    disclosed = true;
    
    var sPlatform = app.viewerVariation;
    var sPos = "5";
    
    var sMsg = "Save to ";
    var sTest = event.target;
    
    var sWorkingDir = "/D/Report Forms/Working/";
    
    if (sPlatform == "Reader") {
      sPos = "5";
    }
    
    if (sPlatform == "Fill-In") {
      sPos = "5";
    }
    
    if (sPlatform == "Full") {
      sPos = "7";
    }
    
    if (sPlatform == "Reader") {
    
    //HIDE MENU ITEMS
      app.hideMenuItem("Save");
      app.hideMenuItem("SaveAs");
      app.hideMenuItem("Import");
      app.hideMenuItem("Export");
      app.hideMenuItem("DocSecurity");
      app.hideMenuItem("DocInfo");
      app.hideMenuItem("GeneralPrefs");
    
    //HIDE TOOLBARBUTTONS
      app.hideToolbarButton("Open");
      app.hideToolbarButton("Save");
      app.hideToolbarButton("ADBE:SPDR:OpStatTlButton");
    
    }
    
    
    if (sPlatform == "Fill-In") {
    
    //HIDE MENU ITEMS
      app.hideMenuItem("Save");
      app.hideMenuItem("SaveAs");
      app.hideMenuItem("Web2PDF:OpnURL");
      app.hideMenuItem("OpnAsPDF");
      app.hideMenuItem("Import");
      app.hideMenuItem("Export");
      app.hideMenuItem("AcroForm:ExportFDF");
      app.hideMenuItem("DocSecurity");
      app.hideMenuItem("DocInfo");
      app.hideMenuItem("Prefs");
    
    //HIDE TOOLBARBUTTONS
      app.hideToolbarButton("Open");
      app.hideToolbarButton("Save");
      app.hideToolbarButton("ADBE:SPDR:OpStatTlButton");
    
    }
    
    
    if (sPlatform == "Full") {
    
    //HIDE MENU ITEMS
      app.hideMenuItem("Save");
      app.hideMenuItem("SaveAs");
      app.hideMenuItem("Web2PDF:OpnURL");
      app.hideMenuItem("OpenAsPDF");
      app.hideMenuItem("Import");
      app.hideMenuItem("Export");
      app.hideMenuItem("AcroForm:ExportFDF");
      app.hideMenuItem("Batch");
      app.hideMenuItem("DocSecurity");
      app.hideMenuItem("DocInfo");
      app.hideMenuItem("Prefs");
    
    //HIDE TOOLBARBUTTONS
      app.hideToolbarButton("Open");
      app.hideToolbarButton("Save");
      app.hideToolbarButton("ADBE:SPDR:OpStatTlButton");
    
    }
    More to follow...
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  22. #22

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Posts
    232
    Thanks alot. I will go through it.
    I appreciate your time and effort.

  23. #23
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Your welcome.
    The best part is comming up still.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  24. #24

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Posts
    232
    cant wait !

  25. #25
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Here is the entire working script with some extra features like file
    name validation to a particular naming format.
    I had to make some changes from the previous post. The position
    of the menu item changed when I moved some code around so
    that is why I posted the entire code again.
    Code:
    disclosed = true;
    
    var sPlatform = app.viewerVariation;
    var sPos = "5";
    
    var sLogin = identity.loginName;
    var sTest = event.target;
    
    var sWorkingDir = "/D/Report Forms/Working/";
    
    app.alert("Welcome user: " + sLogin,3,0);
    
    if (sPlatform == "Reader") {
      sPos = "3";
    }
    
    if (sPlatform == "Fill-In") {
      sPos = "3";
    }
    
    if (sPlatform == "Full") {
      sPos = "3";
    }
    
    
    if (sPlatform == "Reader") {
    
    //HIDE MENU ITEMS
      app.hideMenuItem("Save");
      app.hideMenuItem("SaveAs");
      app.hideMenuItem("Import");
      app.hideMenuItem("Export");
      app.hideMenuItem("DocSecurity");
      app.hideMenuItem("DocInfo");
      app.hideMenuItem("GeneralPrefs");
    
    //HIDE TOOLBARBUTTONS
      app.hideToolbarButton("Open");
      app.hideToolbarButton("Save");
      app.hideToolbarButton("ADBE:SPDR:OpStatTlButton");
    
    }
    
    if (sPlatform == "Fill-In") {
    
    //HIDE MENU ITEMS
      app.hideMenuItem("Save");
      app.hideMenuItem("SaveAs");
      app.hideMenuItem("Web2PDF:OpnURL");
      app.hideMenuItem("OpnAsPDF");
      app.hideMenuItem("Import");
      app.hideMenuItem("Export");
      app.hideMenuItem("AcroForm:ExportFDF");
      app.hideMenuItem("DocSecurity");
      app.hideMenuItem("DocInfo");
      app.hideMenuItem("Prefs");
    
    //HIDE TOOLBARBUTTONS
      app.hideToolbarButton("Open");
      app.hideToolbarButton("Save");
      app.hideToolbarButton("ADBE:SPDR:OpStatTlButton");
    
    }
    
    if (sPlatform == "Full") {
    
    //HIDE MENU ITEMS
      app.hideMenuItem("Save");
      app.hideMenuItem("SaveAs");
      app.hideMenuItem("Web2PDF:OpnURL");
      app.hideMenuItem("OpenAsPDF");
      app.hideMenuItem("Import");
      app.hideMenuItem("Export");
      app.hideMenuItem("AcroForm:ExportFDF");
      app.hideMenuItem("Batch");
      app.hideMenuItem("DocSecurity");
      app.hideMenuItem("DocInfo");
      app.hideMenuItem("Prefs");
    
    //HIDE TOOLBARBUTTONS
      app.hideToolbarButton("Open");
      app.hideToolbarButton("Save");
      app.hideToolbarButton("ADBE:SPDR:OpStatTlButton");
    
    }
    
    app.addMenuItem({cName: "Save to Working Dir...", cParent: "File", cExec: "event.rc = SaveWorking() != 2", cEnable: "event.rc = TestMe() != 2", nPos: sPos});
    
    function SaveWorking() {
      
      var now = new Date();
      var yr = util.printd('yy', now);
    
      var cResp1 = app.response({cQuestion:'Save as ' + yr + '-?????.pdf',cTitle:'Save to Working Directory',cDefault:GetFileName(this.path)});
      
      if (cResp1 == null) {
        app.alert('Canceled');
        return 2;
      }
      
      var sValid = ValidateFileName(cResp1);
    
      if (cResp1 != sValid) {
        app.alert('Not a valid filename format!',1,0);
        return 2;
      }    
    
      if (cResp1 == sValid) {
    
        var cResp = app.alert('Save to - ' + sWorkingDir + cResp1,2,1);
        var sPath = (sWorkingDir + cResp1);
    
        if (cResp == 1) {
          this.saveAs(sPath);
          app.alert("Saved!",3,0);
          return 1;
        }
        if (cResp == 2) {
          app.alert('Canceled',1,0);
          return 2;
        }
        
      }
      
    }
    
    function ValidateFileName(sFileName) {
      
      var sNewFileName = util.printx("99-99999", sFileName);
    
      sNewFileName = sNewFileName + '.pdf';
      if (sNewFileName == sFileName) {
        return (sFileName);
      }
      if (sNewFileName != sFileName) {
        return ('BAD');
      }
    
    }
    
    function GetFileName(sFilePath) {
    
      var sFileName = sFilePath.split('/');
      var i = 0;
      var sNewFileName = '';
      for (i in sFileName) {
        //app.alert('Array element [' + i + '] - ' + sFileName[i]);
      }
      sNewFileName = sFileName[i];
      return(sNewFileName);
    
    }
    
    function TestMe() {
    
      var d = app.activeDocs;
    
      for (var i=0; i < d.length; i++) {
        //
      }
    
      if (i == 0) {
        return 2;
      }
      if (i != 0) {
        return 1;
      }
    
    }
    Let me know if this will work for you.
    This took me a couple of frustrating days to research and figure
    out when I started this for a customer.

    Enjoy!
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width