Visual Studio 2010: Why aren't key combinations available? - ide

I am trying to use VS 2010 for writing C. Frequently, I try to use a hotkey combination, and I get an error message of the form:
The key combination (key, key) is
bound to command (Command) which is
not currently available.
Why is this? Examples include CTRL + R, R for Rename and CTRL + K, CTRL + D for Format Document.
I am trying these commands with my cursor in the code editing window.
I find that this works in 2008 C# but not 2010 C/C++.

As 020Z28 says, the commands aren't supported in the C++ text editor. The workaround for Format Document is to Select All then Format Selection: Ctrl A, Ctrl K, Ctrl F.

The C++ text editor does not implement those two commands. If they work in 2008, it's only because you have an extension installed that adds support for those features.
Edit: The OP currently says "for writing C", just in case the question later changes to "for writing C#."
If the OP actually means C#, then the error is occurring because you are editing a document that is not part of a project/solution you currently have open, or the file has the Build Action set to None.

I have at random found the format document command to be "not currently available". I have found that saving the file and switching to another tab and back, will renable the command.

It may depend on the file extension of the file you are trying to format.
For example, I was testing a BizTalk map (XSLT) which outputs XML. The output file had a .txt extension, and it repeatedly threw the Ctrl+K, Ctrl+D error. When I changed the file extension to .xml, Ctrl+K,Ctrl+D worked every time.
I don't know if VS uses the content or the extension to determine how to format the file, but my thinking is that VS has no idea how to format a .txt file, but it does know how to format a .xml file.

Remove 'tagprefix="asp"' property from register tag.

Related

RMTrak Visual Basic Run Time Error 4248

When attempting to run RMTrak (a requirements mapping software), Visual Basic runtime error 4248 would appear. This only happens on a single file in the set of files being used. Other errors occur when attempting to run RMTrak while the document is currently open.
Run-time error '4248':
This command is not available because no document is open.
- https://support.microsoft.com/en-us/kb/813983 (1/6/2017)
How RMTrak works: RMTrak will open a file, parse it for specific formats, and consolidate it to their viewer. It will use tags inputted into the documents to relate to other other requirements, input specs, etc to show a list of requirements, their mapping, and how it relates.
Open up the document in question and hit "Alt-F11". The VBA editor will appear. Either delete or comment out the VBA code. Save. Re-run.
When RMTrak is parsing the document, it is attempting to run the Visual Basic code that is embedded in the document. Since the document is not being opened by Word when RMTrak is parsing it, the "ActiveDocument" property is invalid.

VBA: set txt to be printed in Portrait mode

this time I'm fighting against a .txt file which doesn't want to be (programmatically) set to be printed in Portrait-mode instead of Landscape-mode (which is the default apparently).
Thing is I know how to do that with application like Word or Excel, but sadly enough I'm working on a device that has no Office at all.
I'm not providing any code at all since my problem is pretty straightforward, and I think I need a simple command in order to solve it. What I basically (programmatically) do in my subroutine is:
Open the file as #1 (I know this appears so '80, but I don't want to modify an up-and-running system, potentially having errors show up)
Write text to the file
Close #1
Save the file
Call text editor shell to show the file to the user
How can I then automatically set the print format to Portrait?
P.s.= I do not have the possibility to insert a userform or an object to print the txt file in "special ways", the user has to print the file from txt editor itself (wordpad just in case)
First to state the obvious: there are no print settings stored in text files (or indeed anything else except for the text). Print settings would be controlled within whatever you are using to print - in this case Notepad or Wordpad.
There are only very limited command line switches for Notepad and Wordpad, which unfortunately don't include page setup. In theory you may be able to automate setting portrait using SendKeys (see here and here) but if it is possible at all it's likely to be difficult and unreliable (focus and timing are two issues).
I can't see a good way round this within the parameters of your question. Adding an object within your application would probably have been the best solution. You might try looking for an alternative text editor you could install that is easier to automate. The only other alternative might be to set defaults within the printer drivers and hope that those stick when the user opens Notepad.

Convert Omniform to PDF in bulk/commandline

We have a large number of Omniform files (around 100,000). We're updating our main server OS from Windows Server 2003 to Windows Server 2008. Omniform isn't supported in Windows Server 2008 so we need to convert these files to pdf (or another viewable format).
What I've tried so far:
Using Print or PrintTo verb from inside a program using Process.StartInfo and using a PDF Writer printer.
Using Print directly from a command line using the Print verb with the PDF Writer set as the Default Printer:
C:\PROGRA~1\ScanSoft\OMNIFO~1.1\OmniForm.exe /p "Test.ofm"
Both of these Print successfully and a PDF appears. However it prints only the Form, not the Form with the entered in Data. Namely you'll get Last Name then a blank instead of showing the entered last name.
If I print to a normal printer and not a PDF Writer I get the same behavior. Form only with no entered in data appearing.
I've tried calling Nuance Tech Support and they suggested doing them manually 1 at a time. Given this would take someone about half a year of full time work to do, that's not a viable option for us.
So what I'm looking for is a solution to the command line print above
If an "image" of the filled-in form might work for you, Omniformat might help you out. It basically converts the file to pdf using a print-to-file method, but it might help you out, since it does batch conversion.

Can an Outlook macro trigger its built-in import functionality?

I'm trying to automate Outlook to automatically load an iCalendar file (.ics) when it starts. I'm aware of the hooks I need to use to arrange the timing already, I just haven't been able to find quality information about what sort of automation is possible.
Since Outlook already has the ability to import iCalendar files well enough for my purposes, I'd prefer to trigger that functionality rather than write my own parsing code. Is that possible?
Depending on what you want, the answer is you cannot do it.
If you want to "import" the ics file you cannot do it alone, you would need for example redemption see here Visual Studio Forum Because MS moves their links often here is a quote from there
“Outlook has no built-in methods to import an ICS file into a calendar item using code. However, a 3rd party library called Redemption (www.dimastr.com/redemption) does have that ability. The SafeAppointmentItem.Import function is called with a file path and item type. So if it's called with the file path where you saved the attachment and a type of 7 (olVCal) you can do what you want. “ Original link is:http://groups.google.co.uk/group/microsoft.public.office.developer.outlook.vba/browse_thread/thread/e4656ad0c5b68b89/d356ce07aeae783d?hl=en&lnk=st&q=import+.ics+file+into+outlook+by+codes#d356ce07aeae783d
So what are you options or what else can you do.
First I assume you are working in something like the application_startup event.
you could "shell" the file - which would have the same effect as double clicking on it.
see here MSDN shell with examples For this you would need the path to your ics file.
But for me in your position, I would be first trying to get the person or thing generating the ics file to change OR I would be just treating it like a text file, parsing the information (which should not be too hard given it is an expected format) and creating my own calendar item in outlook.

How to Pretty print VBA code?

How do you copy VBA code into a Word document and retain the VBA editor color scheme?
You can use Notepad++ to accomplish this in three ways. Just so you know, Notepad++ is a more advanced version of Notepad, which supports syntax highlighting of different code files "out of the box" - Visual Basic included!
Download & install it, fire it up, and load up your VBA code. You should automatically see it beautifully coloured (if not, because the file extension is something other than .vb, go to Language -> VB or Language -> V -> VB).
If you need to change any of the colours, you can easily do so - just go to Settings -> Styler Configurator. From that menu, you can change the various highlighting and font options, to suit your needs - although the default usually suffices for most.
Then, go to Plugins -> NppExport. From there, you have three options you can consider:
Directly print from Notepad++
Copy all formats to clipboard
Export to RTF
Export to HTML
The first is self explanatory. The second one - "Copy all formats to clipboard" - will copy the entire file with the highlighted syntax to the clipboard. Once you click it, then open Microsoft Word or your other favourite document editor, and just hit paste! You should see the beautifully syntax-highlighted code. If something goes wrong, then you can try one of the other options (export to RTF/HTML), although I've never had a problem with the clipboard method.
There are two programs on cnet downloads, which are free to try. In case you did not try them, here are the links:
VB-VBA Code Formatter & Printer 2.2
VBAcodePrint 6.13.110
Smart Indenter could be what you're looking for? You'd load the result into Notepad++, set language to VB and save as .rtf/.doc (or print to file, can't remember off the top of my head).
For a more modern approach, Sublime Text users can install ExportHTML from Package Control. This has the added benefit of being able to include the line numbers, and changing the code coloration.
HTML files can be opened directly within Word.
Highlight supports a wide range of Operating Systems and 150+ languages including Visual Basic, although I'm not sure about VBA.
I would recommend this one: planetB
It works well with Internet Explorer (didn't work wit Firefox for me, not sure abt Chrome).
Plus it's online, so no need to install anything (the case of Company/University PC's)
Regards
Wheeliam
The following works with Visual Studio Code:
Start VS Code.
New file.
Copy & Paste the VBA code into the VS Code window.
In the lower right-hand corner, click on "Plain Text" and select "Visual Basic" instead. Note that the code is now syntax-highlighted.
Copy & Paste the formatted code into Word.