|
-
Sep 19th, 2003, 04:49 PM
#1
JavaScript: Add new menuitem in Acrobat 5.0 [Resolved]
I am having trouble getting this script to run. I have it entered at
the Document level and I need to know where its going wrong.
Code:
function APD_Menu(){
app.addMenuItem({cName: "Save to Working dir...", cParent: "File", cExec: "app.alert("Save to Working directory!");",cEnable: "event.rc = (event.target != null);",nPos: 0});
}
When I try to call my function it gives the error - "SyntaxError: syntax error undefined"
Any ideas or suggestions?
Thanks in advance for any help on this.
Last edited by RobDog888; Sep 25th, 2003 at 04:24 PM.
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 
-
Sep 19th, 2003, 06:23 PM
#2
This is working so far.
Code:
function APD_Menu(){
app.addMenuItem({ cName: "Save to Working Dir...", cParent: "File", cExec: "app.alert(this.path)", cEnable: "event.rc = event.target != null",nPos: 7});
}
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 
-
Sep 23rd, 2003, 02:00 AM
#3
"app.alert("Save to Working directory!");",
Try masking the inner quotes:
"app.alert(\"Save to Working directory!\");",
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 25th, 2003, 01:42 PM
#4
I finally got it to add the menu item and execute some code.
Now I just need to see if I can get it to prompt for verification
before the saveas and handel the response.
Global.WorkingDir is a global static variable that I setup in
another script to contain the absolute path.
Code:
var sPos = "5";
app.addMenuItem({cName: "Save to Working Dir...", cParent: "File", cExec: "var aDocs = app.activeDocs; var myForm = aDocs [0]; myForm.saveAs(global.WorkingDir + 'Test.pdf');" , nPos: sPos});
How do I get a function to return a value so I can embed the
function call into the addMenuItem call?
I can use that to determine if the file is to be saved or not.
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 
-
Sep 25th, 2003, 03:04 PM
#5
Just add a return statement? Or is there any specific reason why this wouldn't work?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 25th, 2003, 04:20 PM
#6
Here is the update that is working.
Code:
var sPos = "5";
app.addMenuItem({cName: "Save to Working Dir...", cParent: "File", cExec: "event.rc = SaveWorking() != 2", cEnable: "event.rc = TypeOfDocSave() != 0", nPos: sPos});
function TypeOfDocSave() {
var d = this.info;
var sTitle = d.Title
var sGood = sTitle.indexOf("APD");
if (event.target == null) {
return 0;
}
if (sGood == "0") {
return 1;
}
else {
return 0;
}
}
function SaveWorking() {
var cResp = app.alert('Save to - ' + global.WorkingDir + 'Test.pdf',2,1);
if (cResp == 1) {
app.alert('Saving to - ' + global.WorkingDir + 'Test.pdf',3,0);
this.saveAs(global.WorkingDir + 'Test.pdf')
return 1;
}
if (cResp == 2) {
app.alert('Canceled',1,0);
return 2;
}
}
This will only be enabled and execute if the document has "APD" in the title.
If there are other documents opened, when switched to them the menu item is disabled!
I still need filename generation code for this part of my prject to be complete.
Review my other thread for the details, please.
Any ideas?
Thanks for the assistance.
Last edited by RobDog888; Sep 25th, 2003 at 04:23 PM.
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
|