|
-
Mar 10th, 2004, 03:17 PM
#1
Thread Starter
Addicted Member
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.
-
Mar 14th, 2004, 03:22 PM
#2
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...
-
Mar 14th, 2004, 08:00 PM
#3
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Mar 15th, 2004, 01:22 PM
#4
Thread Starter
Addicted Member
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:
Set gApp = server.CreateObject("AcroExch.App")
if you have any ideas i would appreciate it.
Thanks
-
Mar 15th, 2004, 01:25 PM
#5
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Mar 15th, 2004, 01:30 PM
#6
Thread Starter
Addicted Member
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.
-
Mar 15th, 2004, 01:39 PM
#7
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Mar 15th, 2004, 02:15 PM
#8
Thread Starter
Addicted Member
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:
Dim gApp As Acrobat.CAcroApp
Set gApp = CreateObject("AcroExch.App")
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.
-
Mar 15th, 2004, 02:37 PM
#9
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Mar 15th, 2004, 02:46 PM
#10
Thread Starter
Addicted Member
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.
-
Mar 16th, 2004, 09:48 AM
#11
Thread Starter
Addicted Member
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.
-
Mar 16th, 2004, 11:31 AM
#12
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Mar 16th, 2004, 11:37 AM
#13
Thread Starter
Addicted Member
but i am only trying to execute the menuitem not add a menuitem? what can be different from vb and asp?
-
Mar 16th, 2004, 11:40 AM
#14
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Mar 16th, 2004, 11:50 AM
#15
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Mar 16th, 2004, 01:03 PM
#16
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Mar 16th, 2004, 04:57 PM
#17
Thread Starter
Addicted Member
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.
-
Mar 16th, 2004, 05:32 PM
#18
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Mar 17th, 2004, 09:07 AM
#19
Thread Starter
Addicted Member
would you be able to give me some code snippet from that?
-
Mar 17th, 2004, 11:05 AM
#20
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Mar 17th, 2004, 11:33 AM
#21
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Mar 17th, 2004, 11:35 AM
#22
Thread Starter
Addicted Member
Thanks alot. I will go through it.
I appreciate your time and effort.
-
Mar 17th, 2004, 11:36 AM
#23
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Mar 17th, 2004, 11:36 AM
#24
Thread Starter
Addicted Member
-
Mar 17th, 2004, 12:37 PM
#25
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|