anyone know best way to open OneNote with supporting command line switches?
For example:
Process.Start("OneNote.exe", "/nologo")
This just opens OneNote and still shows the splash screen. Any ideas?
Thanks in advance.
The way you are doing it now is correct to say. One thing to mention though is the version of OneNote you are using, I believe that only works for 2007 and nothing newer.
You have a few option's to start OneNote with line switches. You can either use the Process.Start or ProcessStartInfo to accomplish this. Please see example's below.
This is straight to the point and will work (depending on the version of OneNote)
Process.Start("OneNote.exe", "/nologo")
Another option to use is ProcessStartInfo (same concept as above, but broken out). I used /paste to confirm this and it pasted what I had in the ClipBoard to OneNote
'Create the new StartInfo
Dim prsi As New ProcessStartInfo("OneNote.exe")
prsi.Arguments = "/paste"
'Start the actual process
Process.Start(prsi)
To view more command line switches you can look https://support.office.com/en-in/article/Command-line-switches-in-Microsoft-Office-OneNote-2007-29468957-1fcc-48b8-8821-00fe5518493a there.
Make it with Dim proc as new system.diagnostics.process
And then use proc.startinfo.arguments = "/nologo"
Do not use quotes around the switch.
Use quotes only around the executable.
Like this:
Process.Start("OneNote.exe", /nologo)
Now, let me add here that a soap dish probably has more knowledge about VB.net than me. So as far as the rest of the call (comma, spacing, etc), I'll trust you've got that nailed. ;)
Related
I recently discovered the blissful convenience of being able to use the File, Save command from within the VBA Editor window to save the currently attached template without having to actually be in the template or close out of Word.
I thought it would be nice to have this command available on a Ribbon Tab or the QAT or even a keyboard shortcut, so I first added the Save Template command to a Ribbon Tab. But when I clicked on the tab, nothing happened.
I thought perhaps I needed to tweak things a bit with a macro, so I recorded a macro and clicked on the command, to see what the VBA statement would look like.
It looks simple and straightforward enough, very similar to a bazillion other "ActiveDocument" macros I have stored that run without any issues:
ActiveDocument.AttachedTemplate.Document.Save
But when I run the macro, I get the standard "Runtime error" message, with no hint as to what is wrong.
I cannot find any documentation regarding this command in any of my source material or anywhere on Google, nor can I find any discussions about it.
Any ideas what's missing here? Thanks in advance!
As I discovered, and Cindy Meister confirmed, the following works:
ActiveDocument.AttachedTemplate.Save
It will work even if the template is closed. The version that you got from the Macro Recorder, ActiveDocument.AttachedTemplate.Document.Save works only if the template is open. The version above works whether it's open or not. I don't program much in Word, but it looks like a template's Document object/property is instantiated when the template is opened and otherwise is nothing.
I was having requirement to run the Macro when we open the document. For that purpose i have created .Dotm template with AutoOpen method. Problem is it doesn't execute. When i add the AutoOpen macro in Normal file it works perfectly.
We don't want to add the AUtoOpen code in Normal.dotm file. How can we achieve the same using different Template file.
I had exactly the same problem. I had 2 separate .dotms with AutoOpen modules that were not auto opening on XP or Win7 x64 both with Office 2010. I subsequently noticed that all my Subs in the AutoOpen module were Private. Hmmmmm. Made my Main Sub Public, left all other Subs Private, and both of them now AutoOpen. Maybe this will help.
"For that purpose i have created .Dotm template with AutoOpen method."
Create new documents with this NotNormalWithAutoOpenMethod.Dotm with File | New.
For an existing document, create a new document based on NotNormalWithAutoOpenMethod.Dotm. Copy the contents of the existing document into the new blank document. Save and Close. Upon reopening the new document, the code should run.
Wasn't me, but I'm guessing you got downvoted because you haven't said what you've tried, what version of Word you're using, or what OS you're on. All of those things are useful in diagnosing the issue.
I'm also guessing that you can not simply save the macro to whatever document you want to run it in, because that should be trivial. Am I correct?
If so, I am trying to do something very similar using Word 2010 on Windows 7 64-bit, but I can't get it to work yet either. The document I need to open is auto-generated from pandoc and is opened in compatibility mode, so perhaps that's my issue. If that's not the case for you, some of the things I've tried might help you.
Use the /t option from the command line: start winword /tmacros.dotm document.docx
If that doesn't work, try adding the /m option as well: start winword /tmacros.dotm /mAutoOpen document.docx.
Instead of naming the macro AutoOpen, try AutoExec or Document_Open.
Note: there is no space between the /t or /m options and the filenames. I've also tried the full path to winword.exe instead of start winword but that didn't make a difference.
Hope this helps, good luck! And please post the solution back here if you figure it out on your own.
Sources:
Command line switch: http://support.microsoft.com/kb/290961
AutoExec/AutoOpen: http://support.microsoft.com/kb/286310
So, I have a program where you can load settings from using the Windows Explorer, opened by calling openFileDialog.
By default, all the files get filtered by their name. Can I make it so that upon clicking on 'load settings' and opening the file selector, it defaults to sorting by date created or modified?
Thanks so much for the help!
It might be possible using Windows API calls, but the solution would be pretty ugly.
See this link for more info
I have to copy files, make a new folder and then paste those files into the new folder so often.
I wonder if we can make a batch file or vbscript file to perform this task? Just select the files and choose "Group to New Folder" from the context menu. That'll be awesome!
I've found a solution in .NET 4.0
http://blogs.msdn.com/b/codefx/archive/2010/09/14/writing-windows-shell-extension-with-net-framework-4-c-vb-net-part-1.aspx
What you want to do is write an HTA application. You could have a selection listbox that could be auto-populated with the current folders files when you first launch the hta. Then just have a simple button than will prompt you for a folder path/name to create when selected and a simple sub to just move the selected files over, maybe through results to the screen or something. Obviously with error trapping and all that's a little bit much code to just paste in here, but it should be pretty easy to do.
If you're looking for help getting started with the hta interface, I recommend you check out the "HTA Helpomatic" which you can use to get the basic GUI, as well as selection box code. Obviously you can write the script subs to do the real work.
I am trying to extract the contents of cmd.exe IDE to a text file using autohotkey scripts ie one test.ahk and its written as shown below:
WinGetText, text, "C:\WINDOWS\system32\cmd.exe"
FileAppend, %text%, C:\ThreePartition\ACTUAL.txt
I am not able to extract the contents. Can anyone please suggest the correct way to do the extraction?
The text retrieved is generally the same as what Window Spy shows for that window.
The Window Spy shows no text elements for CMD windows - what you see is not necessarily what you can get :)
What you can do is to simulate the Select All and Paste commands, and then use the clipboard contents.
I don't believe you can extract the contents of a cmd window without somehow using DllCall to read the process memory directly.
If you just want the output of a CLI command such as Grep or AWK, using stdout via the run command should work. Honestly though, I stopped relying on AHK because this sort of thing is just too clunky.
http://www.autohotkey.com/docs/commands/Run.htm.
Edit for comments:
What you want is doable, but the solution depends entirely on how your IDE works. What behavior does it have that's unique to building a project? If it makes temp files, you can overload your "build" button with an AHK subroutine that watches for the existence of those files, and then checks the modified date of the output executable to see if the build succeeded. The same kind of solution works if the IDE changes its window title when building. Be clever. :)
Failing that, you might have to install a message hook.