Did drag& drop from Outlook stop working recently? - outlook

my program is seeing the drop event but can't get a valid format response. This changed in the last week or so (i.e. working code that used to see a format of 1 (text message) with the name of the attachment being dropped).
dragging from 64bit outlook build 13901.20336 to a 32 bit VFP9 .exe.
drag and dropping between outlook windows (i.e. dragging attachments from email to email) still works.
in the oleDRAGDROP event i have code that tests for known formats and then drops through to search between -64000 to +64000. Nothing is being recognised.
e.g.
do case
case odataobject.getformat(-16378)
m.lctext = odataobject.getdata(-16378)
case odataobject.getformat(15)
*
*
case odataobject.getformat(1)
*
otherwise
for i= -64000 to 64000
if odataobject.getformat(m.i)
m.lctext = odataobject.getdata(m.i)
exit
endif
next
endcase
n
edit:
updated outlook (build 13901.20462 click to run) and problem persists.
for now if my oledragdrop code fails to get a valid .getformat() it assumes dragged from outlook and fetches the first PDF, JPG or PNG attachment on the currently selected outlook item that isn't an embedded image.
Not ideal but probably what is expected about 90% of the time.

odataobject.GETFORMAT("FileGroupDescriptor")
and
odataobject.GETDATA("FileGroupDescriptor")
are still working.
So i just have to extract the filename from that structure and carry on as before.

Related

How do I know when my Ctrl + C command has been processed?

I need to copy the currently selected text from the currently active window in the currently active app.
If the app support guiInfo.hwndCaret, then I use this.
However, in some cases, the app does not support guiInfo.hwnd_Caret, and I have to fall back to plain copying to clipboard to get the currently selected text.
I am checking the WM_DRAWCLIPBOARD message to see when the content of the clipboard has changed.
However, when nothing is selected in the current active window, this message is not called because the clipboard has not changed.
How would I know that the Ctrl + C has been processed anyways?
Thank you!
From MSDN
Each time the contents of the clipboard change, a 32-bit value known
as the clipboard sequence number is incremented. A program can
retrieve the current clipboard sequence number by calling the
GetClipboardSequenceNumber function. By comparing the value returned
against a value returned by a previous call to
GetClipboardSequenceNumber, a program can determine whether the
clipboard contents have changed.

How to get text/range at a point in an Outlook Inspector?

I want to know the text at a point in for example an Outlook email.
In Excel and Word I am able to get the ActiveWindow. Both object models offer the RangeFromPoint method which I have working.
In Outlook the Applicaion object does have a ActiveWindow but it returns either an Explorer or Inspector object.
Further I tried the following code, however it seems the disabled Word Application object in Outlook does not offer the RangeFromPoint.
Dim ins As Outlook.Inspector = olMail.GetInspector
Dim wDoc As Word.Document = ins.WordEditor
Dim w As Word.Window = wDoc.ActiveWindow
Dim rng As Word.Range = w.RangeFromPoint(mousePosition.X, mousePosition.Y)
I am assuming that Outlook's object model will not help me.
Are there any other methods in the Word Document object model that helps me out?
If the Word Object model does not help must I rely on WinAPI?
If I must use the WinAPI what steps do I need to take?
For example;
Convert Screen point to a window point of the window holding the text (body of the email)
get the text at this point.
What is the best WinAPI to get the text at a point in a Window. Is it to SendMessage with EM_GETSEL?
I tried a few things here.
Why I want to know the text at a point.
I am building custom tooltips into office. When the mouse hovers over a point (through the use of the winapi function TrackMouseEvent) I receive from Windows the point where the mouse is. I then need to know in Outlook (Explorer / Inspector) what the mouse is over.
First Thought - Outlook and Word Object Model alone.
As you can see in the question my first thought was to use the same Window object you can use in Word and implement the RangeFromPoint method. But MS decided to not support this in Outlook. So this is a dead end.
The second option here was to use either or both of these
Selection.Information(Word.WdInformation.wdHorizontalPositionRelativeToPage)
Selection.Information(Word.WdInformation.wdVerticalPositionRelativeToPage)
and / or
Selection.Information(Word.WdInformation.wdHorizontalPositionRelativeToTextBoundary)
Selection.Information(Word.WdInformation.wdVerticalPositionRelativeToTextBoundary)
Vertical relative to page always returned -1 even when the text was clearly in view.
The Relative to Text Boundary returned numbers and they changed with positions but I did not work out where the Boundary was when in the Outlook Inspector. Margins did not help me. This could be a way to do this but i did not work it out.
IUIAutomation or Automation
I have no experience with these however my attempts to get the TextPattern failed on Outlook 2007 and Outlook 2010. I name these versions because I found questions here reporting that they were successful with 2013. I think MS at the time intentionally tried to hide the body of the email to stop ummm slow down email viruses.
WinApi
The text body of the email is in a window of Class _WwG and the contents of the window is not visible. You get "message" as the text. Seems here too MS did this intentionally. Thus trying to get the text at a position is not going to work.
Combination of WinApi and Word Object Model
The solution that I found which works with the Explorer reading panes and with all inspectors is to use a combination of the WinApi and Word.
Receive a mouse hover event with point in a window (_WwG Class for Outlook)
Use SendMessage and send a messsage to this window with the WM_LBUTTONDOWN flag.
Get the Word Document from the Inspector.WordEditor method.
The current Range selected will be where the mouse is located in the text.
Expand the range to the word or whatever you need and now you have what is under your mouse.
For read only windows in Outlook there is no caret visible to the user but it still exists and can be found and used.
I have not implemented this on Outlook items that are being drafted (Cursor is in use and visible), but I suppose I will have to move the selection to the mouse position and then move it back to be able to implement it. I could imagine this is not the best for some users.
Edit
There is one issue with this that I could not solve. By sending a click to the window, you click on what is at that point. If there is a hyperlink there, which is the case with email addresses in a mailItem then it follows the hyperlink. I could not work around this issue properly. The only thing I did find in the WinProc was that when the mouse is over a hyperlink then Outlook shows a tooltip and there is a WM_USER + 2 message. Listen for this message and do not click if this message is received.

How can I programatically print a DataReport to a pdf file?

I'm updating old VB6 code to save its DataReports out to a PDF, rather than bringing up a print dialog.
I cannot simply write the PDF within the code (using a VB6 PDF library, etc.), since all our software already uses DataReports, and writing print code for each one would be tedious, at best. Currently, the process requires an employee to print the DataReport to a PDF print driver, naming it manually and saving it to where it needs to go. I need to automate this all, so that the name and location of the saved PDF can be specified programatically, rather than entered by hand.
The best solution would be if DataReport simply had a .SaveToPdf(filename) routine. Worst-case scenario, I see myself automating the process using SendKeys. However, this solution needs to work in an environment with multiple possible printers (so the PDF print driver might not be the default,) and on Windows XP, Vista, or 7.
I've fruitlessly tried Googling the problem, which returns only tutorials on how to do it by hand, much as we do now.
You might consider using a PDF Printer Driver that allows you to configure silent "printing" to a preset directory using auto-generated names.
For an example of such a product, see:
http://www.iteksoft.com/modules.php?op=modload&name=Sections&file=index&req=viewarticle&artid=21
I would create a dialog that lets the user enter the printer (driver) name, directory to save to, and a file naming guideline, then save that to either a local ini file or the registry. You would then need two print buttons / menus. One to print straight to the printer using the default (saved) settings, and one that opens the print window they see now so they can perform a custom print.
Remember an ellipsis on a menu item indicates additional dialogs, Print vs Print...
Just use Crystal Report Viewer Control and follow the steps:
Set objRpt = objApp.OpenReport("type report path and name")
objRpt.DiscardSavedData
dim filepath as string
filepath = report path & report filename
With objRpt
.ExportOptions.FormatType = crEFTPortableDocFormat
.ExportOptions.DestinationType = crEDTDiskFile
.ExportOptions.DiskFileName = 'filepath string goes here
.ExportOptions.PDFExportAllPages = True
.Export False
End With
Follow these steps and the export is done.

Any way to extend or modify drag-and-drop in Outlook with VSTO?

I have an add-in I'm working on in Outlook that relies on drag-and-drop to save an Outlook file to a file automagically. The problem is that the default behaviour is to use the email's subject line as the filename, and emails with extremely long subject lines send an error as there's not enough space in 250 characters to store all of it plus the rest of the path.
I'd like to change Outlook's drag and drop to Explorer so that the default filename is kept to the subject line cut to say 100 characters. Any pointers on where I'd go about doing this?
Ok I think you have a couple of ways to do this.
run you own pane in outlook and on the drop and look at the selection and do a saveAs on each item.
use some winapi to intercept the save ans change the name(i am not sure if this is possible)

VB6 silently deleting huge chunks of control data from forms

My project has maybe 130 controls (total of all labels, textboxes, etc.) in an SSTab (4 tabs). The project loads fine, it runs fine, I don't see a single error or warning at any point, but when I save the form with the SStab on it, the SStab data isn't saved (it is completely gone). Normally the relevant portion of the .frm file looks like this:
Begin TabDlg.SSTab SSTab1
Height = 8895
[1550 more lines of code for all the controls]
Width = 540
End
Begin VB.Menu FileMenu
But lately it's getting cropped to:
Begin TabDlg.SSTab SSTab1
Begin VB.Menu FileMenu
This is very frustrating! In my VB IDE, the frame, sstab, and all the controls are there, editable, running/compiling fine, no error messages at any point, but when you save the file, 1550 lines of precious sstab data just disappears - again, with no warning or error messages. So if you exit and restart the IDE, you get a form load error because 60% of the code is now missing. The log file points to the first error it finds (in this case a Begin TabDlg with no End) - there's no other info in it. (The log file was generated after the code was deleted and saved, so it makes sense that it wouldn't be helpful.)
When I first posted this question, I thought it had to do with the number of controls, because it appeared after I added a control, and in my first few tests, seemed to disappear when that control (or other controls) was deleted. Now I can't seem to get that form to save under any circumstances, even when I delete many controls (bringing the number of controls far below where it was when it was last stable).
I also tried deleting the SStab and moving all the controls to 4 different frames. I successfully did that in the IDE, but when I saved, a huge chunk of the data (starting with a slider control) was missing. So I have no fraking idea what is going on.
The problem is reproducible on two different PCs, so it doesn't appear to be a hardware/corrupt software VB install issue.
Has anyone else run into something like this?
Create a UserControl for each tab. That makes editing MUCH easier. It also allows you to nicely modularize the code, so each tab lives in its own file, and it'll allow you to reuse tabs elsewhere if you want.
Sounds horrible, never heard of anything like that.
Presumably you aren't getting an error log file from VB6 when you load the form into the IDE before it gets corrupted? The log file has the same filename as the form file but with a .log filename extension. For example, if errors occurred when loading Myform.frm, Visual Basic would create a log file named Myform.log. The error messages you might see there are documented in the manual.
Have a look in the Windows Event Log, see whether it records any interesting problems against the VB6 IDE?
Are you using any weird controls? Maybe one of them is somehow corrupting the FRM or FRX. FRM files are just text as you obviously know & the format is documented in the VB6 manual. Can you see any corruption in the FRM in a text editor? If you remove any properties defined in the FRX, does it still fail.
I think I would try creating a new project and a new form, and then use the IDE to copy and paste all the control definitions into it - no code. Play with the new form, see whether it has the same problem. Maybe you can recreate the form this way without the problem. If the new form does have the problem, do the same thing but only take half the controls. Maybe you can find a problem control by "binary search".
I get the same problem when attempting to save a form when the .FRM is writable but the .FRX is read-only
Not sure if this is the issue, but on a VB6 form, there is a limit to 255 (or is it 256) named controls. Perhaps you are running into that?
One way around that limitation is to use control arrays. For example, if you had 10 labels, instead of label1, label2, label3, etc, you could do label(0) through label(9), and use up only one named control.
The other thing worth mentioning about the SSTAB is the way it shows/hides controls. While it may appear that the controls are on separate tabs, what is really happening is that the controls are getting moved waaaayyyyy to the left (and consequently out of view). Perhaps with so many components, the SSTAB is choking on this in the IDE as it tries to render the controls in design view?
Again, not sure if this is the issue, but I know these two tidbits are relatively unknown.
So the SAVE function is not working.
I suspect one of the components you are placing on the tab strip is the culprit.
So ..
1) Take an inventory of each and every kind of component you are placing on the form
2) eliminate one (kind), SAVE
3) Did it SAVE?
-> Yes = that was the problematic control
-> No = return to step 2, but pick another kind
Of course, its important to remove all controls of a certain kind in step #2 (for example, ALL labels, or ALL textboxes, etc).
I have never heard of this happening however.
You are not alone! I've seen this problem. . .in fact I'm dealing it right now, which is what brought me to this site.
I've been working with VB since '94 (VB3) and I first saw this problem about 5 or 6 years ago, while using VB6. My solution then, was not unlike some of the suggestions that you have recieved from the good folks who've responded above: throw out the existing file and rebuild the form in a new file. I did that back and the affected form has worked ever since.
My current problem is appearing in another, much newer form, and the replace/rebuild option (performed about a month ago) only worked for about three weeks. Now the problem is back and each new iteration of the file gets corrupted very quickly. Following the reply above regarding the total number of allowable controls, I'm looking into just how many controls I have. . .and, as it happens, I was in the process of consolidating the primary the buttons and menus into control arrays, simply because it was going to streamline their management.
I can also confirm your observations about moving the project to a second PC. . . I've done that too, and problem persists. Moreover, I can add that I have moved the project from one shared storage system to another to no avail. (The original storage location was on a drive mounted to a Win-tel system and the new location is on a UNIX-based NAS!)
Just rebuilt the file again and checked: Controls.Count = 62, so I am no where near the 255 control limit mentioned previously. This is indeed strange! (Not to mention furstrating!)

Resources