Word VSTO Get the default save location set by Office URI scheme - ms-word

I am creating a new Word document from a template using the Office URI scheme with the nft command using the 'Optional Command argument 2' to set the default save folder.
Is it possible to retrieve the value of this default save folder from VSTO?
I have searched properties of the FileSaveAsDialog, properties of the ActiveDocument, properties of the Application, the CustomXmlParts in the document, and even investigated some WordBasic.FileNameInfo properties to see if it could be found there, but so far without success.

Take a look at the Options.DefaultFilePath property which returns or sets default folders for items such as documents, templates, and graphics.

Related

Project Level DrawnBy Parameter in Altium

I have a Schematic template that refers to the DrawnBy parameter and others to fill in the title block. This works fine if I edit each sheet's document parameters to display the correct information. However, I want to use the project parameters to fill in the relevant information.
The schematic documents have default parameters such as, DrawnBy, Revision, etc, that override the project parameters so each sheet needs to be manually edited for author, dates, and revisions.
How do you override the default document parameters with project parameters?
This would be a better fit for the electronics.stackexchange.com site.
On the schematic document or template (sheet), each field is represented by using the custom text =ParameterName. Once you have the document open in the context of a project, you can add project-level parameters via the menu Project > Project Options, Parameters tab. Add the parameter using the same name that was used on the document. All documents sharing the parameter name will inherit the value entered here.
Don't add any parameter to this list that should be unique to each sheet.
For more information:
Altium Designer: Project Options - Parameters
Electronics StackExchange: Project parameters as variable in Altium

manipulating Microsoft Word DOCX files that have links and track changes using Python

I have been using the excellent python-docx package to read, modify, and write Microsoft Word files. The package supports extracting the text from each paragraph. It also allows accessing a paragraph a "run" at a time, where the run is a set of characters that have the same font information. Unfortunately, when you access a paragraph by runs, you lose the links, because the package does not support links. The package also does not support accessing change tracking information.
My problem is that I need to access change tracking information. Or, more specifically, I need to copy paragraphs that have change tracking indicated from one document to another.
I've tried doing this at the XML level. For example, this code snippet appends the contents of file1.docx to file2.docx:
from docx import Document
doc1 = Document("file1.docx")
doc2 = Document("file2.docx")
doc2.element.body.append(doc1.element.body)
doc2.save("file2-appended.docx")
When I try to open the file on my Mac for complicated files, I get this error:
But if I click OK, the contents are there. The manipulation also works without problem for very simple files.
What am I missing?
The .element attribute is really an "internal" interface and should be named ._element. In most other places I have named it that. What you're getting there is the root element of the document part. You can see what it is by calling:
print(doc2.element.xml)
That element has one and only one w:body element below it, which is what you get when with doc2.element.body (.xml will work on that too, btw, if you want to inspect that element).
What your code is doing is appending one body element at the end of another w:body element and thereby forming invalid XML. The WordprocessingML vocabulary is quite strict about what element can follow another and how many and so forth. The only surprise for me is that it actually sometimes works for you, I take it :)
If you want to manipulate the XML directly, which is what the ._element attribute is there for, you need to do it carefully, in view of the (complex) WordprocessingML XML Schema.
Unlike when you stick to the published API, there's no safety net once ._element (or .element) appears in your code.
Inside the body XML can be relationships to external document parts, like images and hyperlinks. These will only be valid within the document in which they appear. This might explain why some files can be repaired.

TYPO3 extension: how to find certain TS setting

I found in typo3 admin side(/typo3), you can have two ways to set up TS,
you can set up through template->root, I think TS here will affect the whole site.
you can set up through template->certain page, it will only affect this page.
So my question is:
If I want to find where(which page) has TS setting such as : code = LIST, how could I do?
Use Web > Template module it has tools, you can for an example use Template Analyzer for the search
Try querying the database in phpMyAdmin or similar. The following looks in Template Setup:
SELECT pid, config, constants
FROM sys_template
WHERE config LIKE '%code = LIST%'
Replace config with constants to look in Template Constants. pid is the page ID.
If it is not set in the TypoScript, it perhaps has been set in the plugin itself. Just check the plugin content element itself.
In the Template module, go to the page where the setting is in effect.
Use the TSOB (Typo Script Object Browser) to search for "list":
This must show you all TS for this page that contains "list".
If you don't see the setting you can run a cmd/ctrl-F Search over the entire results.
You would have to search for "[code] = LIST".
Which will lead you to the following entry:
Hovering over the label will produce the above tooltip. Copy the line number.
Now change to the Template Analyzer. Here, you can click through all cascading templates and search for the line number:
This is definitely the line that sets that value.
From the "Template hierarchy" tree you will easily find the template that contains the setting.

Exporting custom properties to PDF with org mode

I am using Org-mode in Emacs and have an org document with some tasks. For some tasks, I added a custom property called PEOPLE, which lists the people involved in performing this task.
When I export this document to HTML or pdf, only properties which are "Special Properties" like DEADLINE or SCHEDULE are exported to HTML or pdf and appear in the exported document. I am not able to see the PEOPLE property when I export the document.
Is there a way to add custom properties to the "Special Properties" list of Org mode?
Look into using the "d:" field in the options list (http://orgmode.org/manual/Export-options.html#Export-options) or the :drawers option for html publishing (http://orgmode.org/manual/Publishing-options.html#Publishing-options). Without knowing more detail about how you are doing the exporting, that's the best advice I can give you.
By now what I'm doing is using this http://orgmode.org/manual/Capturing-column-view.html to add a table (with the desired properties) at the end of the document.
It might only work with 8.3, but you can use #+OPTIONS: prop:t or put the list of properties you want to include.
From 12.3 Export settings:
prop:
Toggle inclusion of property drawers, or list properties to include (org-export-with-properties).

Add menu item to Windows context menu only for specific filetype

I've developed an application that load an image using the context menu of window (right click on the file) and for the moment is working, but the reg key is on
HKEY_CLASSES_ROOT\*
and it works with all files.
I want that the menu item on the context menu should be displayed only with .jpg files.
How can I do that? Which registry keys should I use?
Identify the file type (ProgID) for .jpg files
This can be done by checking the default value of HKEY_CLASSES_ROOT\.jpg. It could be anything based on what you've installed, but for the purposes of this example, we'll call it jpegfile, a common default.
Set the context menu item (verb) properties for that file type
You can set per-user context menu items in HKEY_CURRENT_USER\Software\Classes\jpegfile\shell. This key has a list of verbs for the file type. There is a similar key in HKEY_LOCAL_MACHINE\Software\Classes\jpegfile\shell, and these are the system defaults for the file type. You can put a verb key there too, but if the same key exists in HKCU, it will be overridden, so be advised.
Set the command value
The bare minimum key value that needs to be set to get it to work is the default value of the command subkey. You need to set that with the path to your application, like so: HKEY_CURRENT_USER\Software\Classes\jpegfile\shell\open_with_myapp\command would be set to "c:\path\to\myapp.exe" "%1". Now a context menu for .jpg files will have a "open_with_myapp" item which will launch your app when clicked, and pass the file name of the selected file as a parameter. Of course, how your application processes parameters is up to you, so you'd need to set the parameter string to something your app can process.
Set other verb properties
I'd imagine you're probably going to want the context menu item to read something a little more friendly than the key name. You can have the context menu display whatever label you want for your item by setting the default value of that key (open_with_myapp).
That's your basic overview. Definitely check out my answer to this question about associating a file, which has a similar answer:
Create registry entry to associate file extension with application in C++
There's another key on the registry that works independently of user's default programs: HKEY_CLASSES_ROOT\SystemFileAssociations. Since nobody mentioned it on this question... No need to check ProgID before adding the context menu item. Example:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\SystemFileAssociations\.mkv\shell\subtitle]
#="Search subtitles..."
[HKEY_CLASSES_ROOT\SystemFileAssociations\.mkv\shell\subtitle\command]
#="\"D:\\Tools\\subsearch.exe\" \"%1\""
Reference: https://learn.microsoft.com/en-us/windows/desktop/shell/app-registration#registering-verbs-and-other-file-association-information
Additional Considerations:
The HKEY_CLASSES_ROOT subtree can be written to but in general is a view formed by merging
HKEY_CURRENT_USER\Software\Classes
file type registration visible to the current user only
HKEY_LOCAL_MACHINE\Software\Classes
globally register a file type on a particular computer
You can register to those classes instead/aswell
The (ProgID) defined verbs have priority over the same ones defined in ...\SystemFileAssociations\ , but are dependent on that particular Application, When that application uninstalls, it would normally delete its registry entry, along with what modifications/additions you may have done under that key. Or if the default (ProgID) is changed, your modifications will no longer be in effect.
The ...\SystemFileAssociations\ registrations are stable even when users change/uninstall the default programs.
Will publish my working solution derived from the previous answer (and one of its author's other answer).
It also adds an icon. I used it for all file types and didn't have administrator's privileges. The subitem * didn't exist in my registry, I created it myself.
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\*]
[HKEY_CURRENT_USER\Software\Classes\*\shell]
[HKEY_CURRENT_USER\Software\Classes\*\shell\open_with_notepad_pp]
#="Open with Notepad++"
"icon"="C:\\portable\\npp.7.9\\notepad++.exe"
[HKEY_CURRENT_USER\Software\Classes\*\shell\open_with_notepad_pp\command]
#="\"C:\\portable\\npp.7.9\\notepad++.exe\" \"%1\""
UPDATE
Replace * with something like .svg and only for this extension the menu item will be shown.