_3 ) Way 3) Using API “calls”
Using xxAPI calls is computer slang for doing the dll codes in a VBA code via the Declare then use as a normal Function way in VBA code
I almost found a way to do this.. it took a bit of unconventional thinking before I hit on an idea that almost worked..
Execute stuff
Some time ago computer screens were mostly black.
The typical syntax to get something to run was just typing in something similar to the file path , or something that might be recognised by the computer as similar to, the path to the software that you wanted to run. At least that is the way I remember doing it when I was little, at least in the time in between playing with my plonker.
Back in those days you talked about doing stuff. ( Sometimes the word Command was used for what was written or shouted as the message to do something). If you wanted to be a clever poof then you used a word like Execute instead. Computers were clever stuff back then so instead of doing programs they were “Executed”. I executed a lot of early computer stuff- I killed, trashed and broke them
Some of the kids of about that time spent a lot of their time in Penny Arcades playing and playing on older computer. They went on to come up with things like Windows. But often the basic ideas associated with executing in terms of doing and braking stuff are still there and it goes back to when “activating a link” in electronic messaging often exposed an interface giving the possibility of getting some thing done.
Double clicking on a file, or putting a path or URL link in a Windows explorer bar or browser bar often does something similar. The possibility of doing something as an application programmer closely related to these operations is made available in Libraries going by names similar to Windows Shell.
Things of the “Execute” or “Command” nature often involve giving a long string reference path to expose…
As noted previously, .. from Microsoft documentation… Visual Basic provides polymorphism through multiple ActiveX interfaces. In the Component Object Model (COM) that forms the infrastructure of the ActiveX specification, multiple interfaces allow systems of software components to evolve and break existing code. ……. In this sense interface is a set of related properties and methods. Much of the ActiveX specification is concerned with implementing standard interfaces to obtain system services or to provide malfunctionality to other programs.
So delving deep into the innards of computing, I need to look for something, probably in a dll library that has been there a long time doing a lot of damage through the exposing of interfaces looking through long string references paths: There must be one there that the more upper level stuff has used. A good tip seems to be to look for API dll Functions that have been modified a few years back.
http://www.jkp-ads.com/articles/apideclarations.asp
This seems to be what “PtsSafe” is all about. It is almost impossible to find any clear documentation on what that is. But it appears to be an attempt to pull back a bit the Monster of ActiveX roaming uncontrolled in computers..
Sure enough , a bit of searching in documentation they forgot to remove from the internet , or old books, reveals this API function.. which a typical one which need a bit of extra “If VBA7 Then Else” stuff which is done at pre compile to see if your computer is newer and so has the PtrSafe stuff
Code:
Option Explicit
#If Not VBA7 Then
Private Declare Function DoExecCmd Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal Operation As String, ByVal Filename As String, Optional ByVal Parameters As String, Optional ByVal Directory As String, Optional ByVal WindowStyle As Long = vbMinimizedFocus) As Long
#Else
Private PtrSafe Declare Function DoExecCmd Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal Operation As String, ByVal Filename As String, Optional ByVal Parameters As String, Optional ByVal Directory As String, Optional ByVal WindowStyle As Long = vbMinimizedFocus) As Long
#End If
Sub DoExecCmd()
Dim lSuccess As Long
Let lSuccess = DoExecCmd(0, "Open", "mailto: Doc.AElstein@t-online.de")
End Sub
This code brought up some Windows Email thingy.
I guess , just like Outlook. It is there… but god knows how you use it. I tried to send something… because I had never used it before it sent me off on an attempt to set something up:
I had a go:
WindowsEMailSetUp 2 .JPG : https://imgur.com/S7U9cB1
WindowsEMailSetUp 3 .JPG : https://imgur.com/7qGOznM
WindowsEMailSetUp 4 .JPG : https://imgur.com/ww5KZAe
WindowsEMailSetUp 5 .JPG : https://imgur.com/5nkVFB0
It almost worked:
I got an error
WindowsEMailSetUpThenFail .JPG : https://imgur.com/0goEMbZ
Code:
Fehler bei der Verbindung zum Server. Betreff 'test', Konto: 'IMAP4', Server: 'secureimap.t-online.de', Protokoll: SMTP, Port: 25, Secure (SSL): Nein, Socketfehler: 10061, Fehlernummer: 0x800CCC0E
Error connecting to the server. Subject 'test', Account: 'IMAP4', Server: 'secureimap.t-online.de', Protocol: SMTP, Port: 25, Secure (SSL): No, Socket Error: 10061, Error Number: 0x800CCC0E
So I guess it is the same story as with Outlook: You need a hell of a lot of in depth computer knowledge that probably no one ever remembers anymore to set stuff up. Most people using this stuff have this set up already and probably don’t know half the time what it is they are actually doing…
Daniel Appleman “Visual Basic Programmer's Guide to the Win32 API”
https://msdn.microsoft.com/de-de/en-.../bb979032.aspx
_4 ) Way 4) RoutingSlip Object
This is an object available only up to and including Office 2003. Every Workbook( up to and including Office 2003) has such an object. Primarily this is intended to allow simple sending of a Workbook.
Any published codes which work bring up various pop ups asking for information. I have no idea what they all mean and I can’t find any documentation or Blogs to explain this or show any working example.
I suspect this way might also require some interaction with some existing Email program.
So I do not see it as a realistic option.
http://www.snb-vba.eu/VBA_Excelgegev..._en.html#L_2.2
https://msdn.microsoft.com/en-us/lib...ffice.11).aspx
https://msdn.microsoft.com/en-us/lib...ffice.11).aspx
_5 ) Way 5) sendmail Object
This is a method which allow simple sending of a Workbook
This is one single code line. The coding is not the issue: …. As with ways 2, 3 ,and 4 , it attempts to call up an existing Email program. It requires all sorts of complicated setting up specific for each computer and Email program.
It is therefore not a practical solution in my opinion.
https://msdn.microsoft.com/en-us/vba...l-method-excel
Final conclusions to VBA to automate Send and Automatically Sending of E-Mails and Excel File Workbooks.
There appears to be only one realistic way to do this: Way 1 : Use the CDO (Collaboration Data Objects ) object library available in VBA
I was able to apply this way very well.
It allows you to send full formatted messages and attach files completely from VBA.
The code can be run from VBA Word or VBA Excel.
This allows for an easy customisation to suit a particular requirement involving automating of sending E Mails with attachments.
There do not appear to be any other ways to do this. The other published ways and codes which I investigated are very reliant on other program settings: They are dependant on existing Email programs and require extensive setting up on as particular computer system. They do not really use VBA to automate Sending Emails. They are simple additions or “add -ons” or “pseudo Buttons” to set off an existing Email program.
I was very surprised by this… and so where almost half the authors of published codes that I contacted. I likened their sharing of their codes as similar to giving a train ticket valid from Berlin to Munich to an Aborigine wanting to go to Munich: Very useful to him… as long as someone else takes him and organises putting him on a train in Berlin.
Ways 2, 3 ,and 4 are minor additions to something else and are no solution alone to Automatically Sending of E-Mails and attachments.
Ref:
http://www.snb-vba.eu/VBA_Excelgegevens_mailen_en.html
https://powerspreadsheets.com/send-email-excel-vba/
http://www.ozgrid.com/VBA/send-email.htm
https://stackoverflow.com/questions/...books-with-vba
http://www.databison.com/3-nifty-way...l-using-excel/
Bookmarks