How can I tell if Office Clipboard collection is turned on? - winapi

I want to know whether the Office clipboard collection is turned on. This is the clipboard pane that saves the last 24 clipboard data. On Office 2007 and 2010 you get it by expanding the clipboard area on the Home ribbon, and in Office 2003 you can open it from the task pane area, and selecting clipboard from the menu.
I've an Office plugin.
Although I'm doing all sort of API hooking (using IAT), I'm looking for the simplest solution.
My initial idea was to look for a window with title: "Collect and Paste 2.0" (check out yourself with Spy++), with various Windows class (e.g. in Word it is bosa_sdm_msword). However, users can check the 'Collect without showing Office clipboard', and restart Office. At this point, Office will collect data without any sign to the Window.
I am looking at registry key: Software\Microsoft\Office\%d.0\Common\General\AcbOn. This is cool, but this entry isn't saved until user exit Office. Hence, users can open a different application, turn on collection, close the window.
Office clipboard creates an icon in the notification area. See question: how to acquire list of notification area icons?. Unfortunately, this question got no answer that work. If you know the answer for this, please reply here or on that question (you'll get +1 twice!)
As I said, I'm inside the process of the application and I'm able to intercept anything that has an export symbol, but I'd like to minimize the effect on the application. For example, intercepting send message, or subclassing a Window will have an effect on the performance (and in some cases: stability) of the Office application.
In Office 2003 there is a window with a class named ('ActiveClipboard'), but I can't find it on 2007 and 2010. On the other hand I see WM_USER+2304, which I don't know what it is.
Has anyone went through that path? Any hint?

Answering my own question:
As far as I can tell, Office doesn't have any event or API in the object model to tell you whether Office is collecting the clipboard. However, the combination of these two methods is working for me:
Enumerate all windows in the system, and search for a Window with the following attributes (class name/title respectively):
Word 2010: "bosa_sdm_msword", "Collect and Paste 2.0"
Word 2003: "bosa_sdm_Microsoft Office Word 11.0", "Collect and Paste 2.0"
Word 2007: "bosa_sdm_Microsoft Office Word 12.0", "Collect and Paste 2.0"
Excel (all): bosa_sdm_XL9", "Collect and Paste 2.0"
PowerPoint (all): "bosa_sdm_Mso96", L"Collect and Paste 2.0"
If such a window exists, this means Office is collecting clipboard data.
Search registry key: HKCR\Software\Microsoft\Office\14.0\Common\General\AcbOn (REG_DWORD). A value of 1 well tell you Office is collecting data.

Related

How do you disable the office 2013 clipboard?

This is what I tried:
[HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Common\General]
"AcbControl"=dword:00000001
but the office clipboard still appears. Does this reg flag still work as described in this Kb?
And it did get set:
AcbControl does not disable the Office Clipboard, it merely disables/enables the automatic showing of the Office Clipboard pane.
You can test this manually by enabling the option "Show Office Clipboard Automatically":
If you now check your registry it will get an AcbControl entry with value 0
Now switch off the "Show Office Clipboard Automatically" option:
Check the registry again and notice the AcbControl switched to 1 (refresh RegEdit if you don't see it right away)
If you now copy twice you'll see that it still uses the Office Clipboard, but it just didn't change the status of the pane from invisible to visible.
So you can't turn the Office Clipboard off (you can programatically capture Copy commands and if detected clear the copy buffer, but I don't sense from your question that this is what you are looking for)
To completely disable Office Clipboard - use decimal value 2147483648 (or hexadecimal 80000000).
Source: https://support.microsoft.com/en-us/help/2817672/macro-takes-longer-than-expected-to-execute-many-individual-copy-and-p

How to make Outlook "Attach File" always use default location

I've done a fair amount of Googling on this and seem to be asking the opposite question to everyone else.
In Outlook 2010, how can I make "Attach File" always show the default location rather than showing the last location visited after the first time of use.
I have set the default location and this is shown when attaching a file the first time after opening up Outlook. I want Outlook to not remember where I've been in this instance. Closing Outlook and opening a new instance appears to be the only way to make it use the default location again.
In summary - How do you stop Outlook, and Office apps in general, remembering the last location visited?
Thanks
I submitted this question on the Microsoft Answers site and was informed that what I would like to achieve is impossible.
The closest functionality is to add the required location to the Favorites section of the navigation pane; requiring a single click.
Full answer here

Locked excel sheet that isn't open

I am trying to open a locked excel sheet. The warning says it is locked because it is being used by "AN Other".
This person does not have the sheet open, does not have any excel applications open, does not have any excel based tasks running in the task list and has tried the good old "turning it off and on again".
Neither of us can save onto this filename, change it in windows explorer or delete the file.
We have "saved as" another name but really need the original name. I looked at a few forums and they suggest this is an excel/windows bug.
Am using excel 2010 and Windows 7.
You need to get in touch with your IT support.
In a company network, a file will be locked for other users when somebody edits it. It can happen sometimes that the file does not get released (unlocked) when the user closes it. Your IT Support people need to unlock the file, so you can edit it again.

Save Outlook Email as text file, and then run a script on it?

I'm using Outlook 2007. I have no experience with Windows programming or VBA, as all of my background is on Unix systems. I am attempting to have Outlook save each incoming emails as text file, and then a run a python script which will parse this text file.
I found this question which seems to provide some VBA code to accomplish the first task, but I'm not sure how to utilize it. I open the Visual Basic Editor, but have no idea how to proceed from there. I tried saving the text as a module, but when I attempt add "run a script" in an Outlook rule, no scripts are available. What am I doing wrong?
EDIT: Clarification.
I'm assuming you're familiar with coding at some level, even if not on Windows. You may want to do some general background reading on Outlook VBA; some resources on this would be a Microsoft article, this article from OutlookCode, and so on - there's a ton of resources out there with walkthroughs and examples.
Addressing your specific question: take a look at this Microsoft KB article, which describes how to trigger a script from a rule.
The key to getting started once you've gotten your VBA editor open is to double-click a module on the left, for example ThisOutlookSession (under 'Microsoft Outlook Objects').
That should give you an editor you can paste code into. Bear in mind that (per the above MS page) your procedure must accept a MailItem object, which will be the item that the rule has in hand, so the linked example you gave would have the first couple of lines changed from:
Sub SaveEmail()
Dim msg As Outlook.MailItem
' assume an email is selected
Set msg = ActiveExplorer.Selection.Item(1)
' save as text
[...]
...to:
Sub SaveEmail(msg As Outlook.MailItem)
' save as text
[...]
Essentially you're being handed a MailItem rather than having to create it and connect it to the selected item in Outlook.
To achieve the second task of 'running a script' on the file, I'm assuming that you want your VBA to make changes to the file after it's been saved? This is pretty straightforward in VBA, and you'll find lots of examples for it. One pretty simple outline is in this answer.
Edit based on comments: to launch an external tool, you can use either the Shell command if you don't need to wait for it to complete, or you can use one of the many Shell-and-wait implementations floating around, for example this popular one. Or, you can use the WScript approach in this answer.
Note that you'll need to ensure Outlook is set to allow macros to run, and you will probably want to sign your code.

How do I convert Word files to PDF using Word 2007 programmatically?

I used to convert Word documents to PDF via Word Automation: Enumerate the CommandBars until one containing "PDFmaker" was found, enumerating its controls and executing it.
With Word 2007 this no longer works - although the PdfMaker Com Addin is installed and accessible via the Acrobat menu.
PDFmaker is required for quality reasons. Therefore I cannot use the Microsoft "Save as PDF" addin; so the SaveAs method described in another post here is not applicable.
Any ideas?
A common way to get a PDF out of Word is to print to a virtual PDF printer. I could bet you have one installed. Maybe you find the quality appropriate.
The code would be:
Application.ActivePrinter = "whatever PDF printer you've got"
ThisDocument.PrintOut OutputFileName:="c:\whatever.pdf", PrintToFile:=True

Resources