Good morning,
I would like to sync my Excel Spreadsheet with Outlook calendar.
This spreadsheet is to be updated every 5-10 mins. Is it possible to set some periodic updates or shall I do everything manually?
I found a lot examples in the web, showing how to export Excel data to Outlook, but there are only single operations, that must be repeated.
One reasonable option is provided here:
https://classroom.synonym.com/sync-yahoo-calendar-android-device-8556.html
but is pretty much other way round what I am looking for, because it's embedding calendar to the Excel.
I would like to link Excel Sporeadsheet with Outlook calendar.
Is there a some way to do this i.e via VBA, PHP, SQL etc?
Usually programming such an action can be done in two ways: Polling or event driven.
Polling means using a timer to do your work repeatingly every period of time. Search for 'VBA' and 'timer'.
Event driven means you will take a subscription on an event. The other side will raise an event when something has changed. Like a subscription on a newspaper: the newspaperboy delivers a newspaper when something happened in the world. When you hear or see the newspaperboy, you walk to the mailbox and empty it.
Usually event driven is the most beautiful solution, because it doesn't use a lot of CPU (with the newspaper example, you can sit back and relax until a newspaper is delivered). But when you are polling, you will have to check the mailbox (calendar) every time.
Here is a Items.ItemChange event about when an item has changed. I hope it fits your needs. If you want to understand better how it works, search for "event handling".
If the link is broken, here is the example from that page:
Public WithEvents myOlItems As Outlook.Items
Public Sub Initialize_handler()
Set myOlItems = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderCalendar).Items
End Sub
Private Sub myOlItems_ItemChange(ByVal Item As Object)
Dim prompt As String
If VBA.Format(Item.Start, "h") >= "17" And Item.Sensitivity <> olPrivate Then
prompt = "Appointment occurs after hours. Mark it private?"
If MsgBox(prompt, vbYesNo + vbQuestion) = vbYes Then
Item.Sensitivity = olPrivate
Item.Display
End If
End If
End Sub
Related
I have an Excel workbook that pulls fact tables from Dataverse for Teams via Power Query. This workbook is shared across our organization. The users are (for the most part) technically naive. So when a query fails to refresh due to lack of authentication, I need the authentication dialogue box to automatically pop up.
I'd like to write a Workbook_Open sub to check if the user is signed in to a particular OData connection. If they are not, I'd like to call the dialogue (pictured above) so that they can sign in before it causes them any issues.
My problem is, I can't find any documentation showing which object(s) and methods to use. Any ideas?
You might call this Sub as the application will use the users default browser to establish a new window:
Sub sbVBA_To_Open_Website_URL_FollowHypderlink()
Dim strURL As String
strURL = "https.//org16c3abbe.crm.dynamics.com/"
ThisWorkbook.FollowHyperlink (strURL)
End Sub
First of all, I already found out how to list default event names of Excel UserForm Controls using Typelib Info referenced as TLBINF32.DLL.
I shared it here.
It is a part of my ongoing project to create codeflow diagrams and possibly VBA code obfuscator early alpha version available on GitHub.
The issue now, is, with trying to list Event Procedures of the UserForm itself:
Unlike listing UserForm Controls using TLI-ClassInfoFromObject(UserForm1.CommandButton1), I found out the hard way that I need to use TLI-TypeLibInfoFromFile("FM20.dll") because if I use ClassInfoFromObject(UserForm1), there is an error.
I also found out that I can use TLI-ClassInfoFromObject(ThisWorkbook.VBProject.VBComponents("UserForm1").Designer).
Using FM20.dll and .Designer methods both get 16 event procedure names.
I can manage/understand up to this far.
Then I manually counted the UserForm's event procedure dropdown list in Excel VBA Editor and found that there are 22 UserForm event procedures.
But after I ran the following code using TLI, the resulting list contains 16 event procedures only, as shown in the first photo.
I am using MSForms class/object from FM20.dll.
The code is as follows: (Needs Reference to TypeLib Information library at C:\Windows\SysWow64\TLBINF32.DLL)
Sub listUFEvents()
Dim t As TLI.TLIApplication
Set t = New TLI.TLIApplication
Dim ti As TLI.TypeLibInfo
Set ti = t.TypeLibInfoFromFile("C:\Windows\SysWOW64\FM20.dll")
Dim cci As TLI.CoClassInfo
Dim mi As TLI.MemberInfo
Dim i As Integer
For Each cci In ti.CoClasses
If cci.Name = "UserForm" Then
For Each mi In cci.DefaultEventInterface.Members
i = i + 1
Debug.Print CStr(i), mi.Name
Next mi
End If
Next cci
End Sub
6 events were not listed including UserForm.Activate and UserForm.QueryClose etc.
My question is, why those 6 event procedures were not listed?
If these event procedures were not picked up from the TypeLib in FM20.dll, where do they come from?
Object Browser also shows only 16 procedures.
Or did I do something wrong in using TLI library?
I admit that I am pretty far from becoming/being an expert.
I am still trying to understand how TypeLib Info works.
How do I get all 22 event procedure names?
I need the event procedure names to differentiate user-defined procedures from the event procedures in a UserForm CodeModule in my project which is about listing the procedure calls in a VBA project.
I can't find anybody asking the same question anywhere either.
Edit:08FEB2021
Added project userform image + zoomed one, to clearly show and better explain the question
In the following zoomed photo,
A->, UserForm controls' default event procedures' names
B->, UserForm default event procedure names
C->, User-defined Sub+Function residing inside UserForm CodeModule
Above image is zoomed for better clarity.
***********************************************************
I want to separate B from C like I did with A.
***********************************************************
So that we can know that default event procedures were NOT called directly.
The image below is presented to get a better idea of why I am needing to list the names of the UserForm event procedures.
Apology
I apologize for being a bit political (if you wanna call a function name politics!).
I truly am sorry to have to involve a bit of politics here.
I am not asking for anything except your awareness. Give me a negative vote if you want, for doing what a man needs to do when his country needs him most.
I just want to do something, however small it may be, as a citizen of Myanmar.
Normally, I am not interested in politics but the current situation calls for me to let the world know that Myanmar is currently under siege by a Military coup which forcibly removed democratically elected government and currently oppressing its citizens' rights.
Please bear with me and I hope you all can understand and empathize with me.
Thanks for your kind understanding.
The TLBINF32.DLL does what it is designed (coded) to do, so there is nothing you can do to make it recognize the five events related to MSForm's multiple "open/close" steps, or the MSForm's own window's Resize events. If you want to use them in your code you can, for example, create string constants for the event names you need, or keep them in a lookup table in a worksheet, or in a text file you will read, or whichever other way that suites your project.
As for listing Excel UserForm Controls, you do not need TLBINF32.DLL at all because it's already built (obviously, since TLBINF32.DLL just taps into this) into the MSForm class. To test this, please create a form, name it, say, "Form1", throw in a few controls and run the following simple subroutine from anywhere within the VBA project:
Sub ExamineControls()
Dim ctl As Control
For Each ctl In Form1.Controls
Debug.Print ctl.Name, ctl.Top, ctl.Visible ' anything else you need?
Next
End Sub
It does not matter whether the Form1 is opened or not.
I hope this is helpful.
This is my first post in this site. I've found suggestions in the past provided by this site, but I never had to ask something directly such as today.
I've been using Microsoft help files with the topic, but after given up and clicked on contacting Microsoft for help, it suggested to join this site.
I've been asked to create a macro to update various documents without Publisher. I never used Publisher and soon realized there's no macro record function.
The macro does functions that I need it to do with a few exceptions and 2 are listed below which i need help with.
FIND/REPLACE TEXT.
I'm able to use the above function, and I'm able to replace text however in one instance the document has 2 bullet's on an outline and i need to create a 3rd. I look for the last few words on bullet 2, but can't figure out how to do a carriage return or a simple 'ENTER' like if you were to do it manually in order to start a new bullet.
in Excel i use CHR(10) or CHR(13) but it doesn't seem to work here, even though i am coding in Excel. I found posts suggesting VbTab, VbCr, VbCtrl, but i never used those and can't seem to get them working.
FIND TEXT
Some documents are outdated and i don't want to create a new version (the code wouldn't make any changes, however it would still SAVE AS with a new document name. I need to verify if certain words exist and only then, proceed with the changes.
I found this code on Microsoft web site but... it only works the 1st time around.
.FoundTextRange - after the 2nd time around this object is always set to 'Nothing' even though i see the words i'm searching for.
Dim objFind as FindReplace
Dim fFound as Boolean
Set objFind = ActiveDocument.Pages(1) _
.Shapes(1).TextFrame.TextRange.Find
fFound = True
With objFind
.Clear
.FindText = "Urgent"
Do While fFound = True
fFound = .Execute
If Not .FoundTextRange Is Nothing Then
.FoundTextRange.Font.Bold = True
End If
Loop
End With
Any help would be appreciated.
Thanks,
I may have stumbled on an answer for the 2nd part. It seems the object for the publisher application is required in front of 'with Activedocument.find' = with AppPub.activedocument.find. On MS web site, it does not reference this.
The error then happens throughout the macro whenever 'Activedocument.find shows, it works once i apply the AppPub object reference.
If someone can suggest how to add new bullet points, that would be helpull.
I have other questions related to publisher...
How do you center a text box after it's been expanded? (i have to make it wide in order not to hide added text (wider and longer), but the wider change, only changes it to the right, not both ways.
how do you add a check box. The doc has existing checkboxes. When i copied the existing text box, that worked, but the box is very small. I tried Windings, but the box is different than the others.
I have VBA code that iterates through emails in an Excel file and populates the bodies of Outlook emails with different criteria that relate to the recipients of the emails.
I want after each automated creation/draft of an email to wait with the draft email open for the user to manually check then send the email. The program would then continue by drafting the next email and prompting the user to check it before sending it.
I am wondering if you can have a While loop within a For loop.
The For loop iterates until all emails have been sent.
The While loop gets its criteria from Outlook. "Did the user send the email? Yes? Draft the next one".
I could not find any resources online. I don't have any code. This question is for directional help. Do you have other suggestions?
What you want to do would be difficult to architect with VBA but not impossible. I would recommend a COM add-in. Regardless, there's no concept of a wait cycle in Outlook that would work in your favor. You will need to maintain a collection of Inspector windows that you add to or remove based on the Inspectors.NewInspector and Inspector.Close events (this is known to Outlook devs as a "wrapper model"). From those Inspector objects you can obtain the MailItem object from Inspector.CurrentItem, and from there you can trap the MailItem.Send event which you can cancel based on user review or proceed to set some internal variables that you can track for managing these send events you're monitoring.
If the wrapper model is too complex, you can just trap single instances of when those events fire, but new windows would fire the event anew and you would lose your "connection" to the item.
For general VBA help, see the Outlook Object Model documentation or OutlookCode.com (old but still relevant).
Good morning,
I have develop a note application which is used to make a booking. This application is used by multiple user at the same time.
I am quiet new to this development and now I would like to develop a functionality so that user can print a export data to excel.
I have created a view (Shared) where its Selection Formula is base on critical each user specify in a search form. I have problem when a user is being printing and yet finished, the other users is also clicking printing same time, the result of export data on the sides are the same to the one who created first.
I was thought may be using the kind of (Shared, Private on first Use View) but it generated an error [Notes error: Index is not to be generated on server ("view name") ] at the points where I called
view.Clear
view.SelectionFormula = formula
uiw.ViewRebuild
I have no idea how to solve this problem. Could you please advice how this problem could be solved?
Thanks your in advance for your great help.
Best regards,
Veasna
There are different ways to do this. One possibility is to use a "shared, private on first use" (spofu) view: then every user gets his own copy of the view, and they don't impact each other. But I think it is not a good idea to do it like that, as every user needs designer rights to change the selection formula of the view. This is something you do not want.
A better way would be to use a spofu folder for each user and put the documents in it like this:
Dim ses as New NotesSession
Dim db as NotesDatabase
Dim dc as NotesDocumentCollection
Dim folder As NotesView
Dim formula as String
Set db = ses.currentDatabase
Set folder = db.GetView("NameOfTheSpofuFolder" )
'Make it empty
Call folder.AllEntries.RemoveFromFolder("NameOfTheSpofuFolder")
'Search documents based on the formula
Formula = "Field1 = 2 & Field2 = 5"
Set dc = db.Search( formula, Nothing, 0)
Call dc.PutInFolder("NameOfTheSpofuFolder")
Spofu folders need a little "care" but usually they work quite nicely.
This code is not tested and just written down without syntax check etc. It might contain typos, but should give you an idea how to start.
You could create a Lotusscript agent to export the data the users specify.
Get the search criteria from the form, then use db.Search or (preferably) db.FTSearch to get the documents to export.
Now you can export the data of those documents to Excel, using one of the techniques described here:
http://blog.texasswede.com/export-from-notes-to-excel-3-different-ways/
If you want to export as CSV, you can use this code as a start: http://blog.texasswede.com/export-notes-view-to-excel-with-multi-value-fields/
According to this thread on the Notes 6/7 forum, there may be a workaround for this problem. You haven't shown enough code to know for sure. If you are using getView() to access the Shared - Private On First Use (SPOFU) view, that doesn't work. The workaround is to loop through the db.Views() array, checking both the Name and Readers properties in order to make sure that you get a handle on the private instance of the view instead of the shared instance.