Need to automate Sending Telegram Messages for the next 14 Days - automation

I have a Telegram Group that I recreate every 2 weeks. I then have a list of messages & media that need to be sent at certain times in the next 2 weeks. I am using Telegram's "Schedule Message" that I set up on the first Sunday evening. I am looking for a way to automate this whereby I have a sheet that has the details & it can be read & posted into the group... Something like this
06/02/2022 8:00pm "Message1...."
07/02/2022 9:00am Pic1
07/02/2022 10:00am Pic2
07/02/2022 10:30am "Message2....."
Any ideas how I can automate this? Instead of doing this every 2 weeks manually.

use telethon! it's as easy as doing:
pip install telethon
https://docs.telethon.dev/en/stable/modules/client.html#telethon.client.messages.MessageMethods.send_message here you can find the part about scheduling :)

Related

Change Outlook appointment series having a starting date in the past

maybe you've experienced this, too. When I get involved into a project that is already running the project lead or scrumm master forward me appointment series like daily stand-ups or similar and the series started long before the day I receive the invitation.
Let's asume the following as example:
The series starts on January, 11th 2021 (Monday) and re-occurs every week.
I receive the invitation in my inbox on March, 16th 2021 (Tuesday).
When I look into my calender I will see this appointment in January, February etc. although I didn't participate back then because I wasn't assigned. To keep my calender in a way that it shows what really happend I have to manually remove all those occurances.
What I want to archieve is this:
The invitation enters my inbox.
Application_NewMailEx is triggered and runs a piece of VBA code that checks for a series like the following.
(...)
If TypeName(objInboxObject) = "MeetingItem" Then
Set objAppt = objInboxObject.GetAssociatedAppointment(False)
If Not objAppt Is Nothing Then
If objAppt.IsRecurring Then
Set objRecurrPatt = objAppt.GetRecurrencePattern
If Not objRecurrPatt Is Nothing Then
(...)
That's easy to handle but now the tricky part that I cannot find a solution anywhere and I really hope one of you can help me.
How I can I find out the NEXT FUTURE occurance starting from TODAY (the date I received it)? In the example this would be March, 22nd 2021. Especially if the re-occurance pattern is more complex than in the example.
Then I would replace the start date of the series with this calculated date and save the MeetingItem. If I accept it in the normal Outlook window I will have one calendar entries in the future and none in the past.
Analyzing the RecurrencePattern object you can find the date of the next occurrence. Then you can use the RecurrencePattern.GetOccurrence method which returns a specific instance of the AppointmentItem object on the specified date. The GetOccurrence method generates an error if no appointment of that series exists on the specified date.

Iress feed - Excel and VBA

So I am running a spreadsheet with a whole bunch of stock codes.
I don't have any problem going via the IRESS addin for excel to get a data feed of prices.
However in my sheet, it gives the option for client to stocks and then it pre-populates a table with information such as stock code, price. However it also is meant to do a calculation of how many units a person would have if they were to invest $x amount into each stock. The problem here is when I run a macro, the iress feed does not refresh and just shows #Value in the cell.
However when I end the macro, the prices start feeding.
This is what I get:
The macro breaks when I try to calculate the units.
For formula that the code enters into the cell is:
Cells(i, cp.Column) = "=IRESSRtd( ""Quote"" , ""13"" , ""0"" , "" " & Cells(i, stock.Column) & """)/100"
'i' is a loop starting at the first row where there is a stock code, to the lastrow where there is a stock code, then under the "current price" column, it enters that formula.
cp.column is the column reference for 'cp' where 'cp' is set by a .find function.
Same with the stock.column reference.
Might be a bit of a long shot, but does anyone know how I can get the Iress feed to update without having to stop my macro?
IRESS support recommends to either use the UI of the Excel addin to generate the RTD links, or if you really want to do a lot more number crunching in the VBA you could call the IRESS API directly - i.e. IRESS Server API COM interface calling the PricingQuoteGet method (with Updates enabled). There is a sample on getting quote info back in the IRESS help files ā€¯IRESS PRO FE > Help | API Documentation | IRESS Server API | Programmer's Guide

How can I make the same set of conditional statements apply across all subroutines in vba?

thank you very much to those who answered my original question. I'd like to go into a little more detail about the problem I am having. I am working on a macros that provides a visual representation of the 4 different production phases of a product we produce. The spreadsheet is set up to appear as a linear calendar, showing all 365 days of the year and grouping them into calendar weeks. Each production phases has a different color associated with it. The four buildphases are:
1) Assembly: 1 day (yellow)
2) Initial analysis: 1 day (purple)
3) In-depth analysis: 7 days (green)
4) Shipping: 1 day (red)
No work is performed in the facility on weekends or holidays. Saturdays and sundays are represented by a cell colored black and holidays are represented by cells colored orange and having a criss cross pattern. The macro is designed to skip these holidays using the following if then statement:
Dim i As Integer
i = Analysis days
for i = 1 to 7
ActiveCell.Select
If Selection.Interior.Pattern = x1CrissCross And Selection.Interior.Color = orange Then
ActiveCell.Offset(0, 1).Select
Else: ActiveCell.Select
End If
If Selection.Interior.Color = black Then
ActiveCell.Offset(0, 2).Select
Else: ActiveCell.Select
End If.
The If Then statement that tells the macro to skip Saturday and Sunday works every time. But the statement that tells the macro to skip holidays only works part of the time, and if the holidays last longer than a few days (Christmas vacation lasts nine days) the macro inserts production work days interspersed throughout the holiday. I've found that by copying and pasting the above statements directly beneath one another several times seems to fix the issue. But I am sure there has to be a more efficient way to do this. Does anyone know of a way I can fix the issue without having to copy and paste the same lines of code mulitple times?
Thanks in advance!
If you are looking for a way for make a test and store the result globally in your code, so also in the other functions/subs you can access the data prevoiusly tested take a look here.
If you are lookin to a way to compact your code and write something like
b = check(a)
instead of
if a="xx" then
b = "something"
else
b = "something else"
end if
take a look to this link for functions/subs explanations

Auto creating a task-manager

I would like to create a task manager using macros, but I have no idea how i can do it with the sheets i am using atm.
I made a sheet which shows
- Who wil execute the task
- What is the urgence of the task
- Where should it be done
- On what construction-element the task should be done
- What is the task that should be done
- A empty-line to place notes.
In excel my sheet wil look like:
The A1 line wil be headers.
A B C D E F
A1 Executer Urgence Location Construction-Element Quantity Activity
A2 Housemaster 1 Livingroom Door 2meter Replace
A3 Technical Deperartment 4 Kitchen Ceiling 0,5meter Fix
A4 External company 2 Bathroom Floor 1 meter Repair
I would like excel to auto-create new tabs for every executer. So each executer get a tab with all task he or she should do.
Excuse me for my poor english, its not my native language.
Thanks in advance!
Copy the sheet for each executer and give them the executers name. Then go thru each of that new sheets and delete all rows where the executer name is different from the sheet name. This can all be done via VBA so that you have a fully automated solution on the end.
But that's not been done in one or two rows so you can not expect that we provide the complete code for that ;-). Let us know when you have a specific problem on one of the steps.

VBA Excel 2003/2007: Declaring, Filling, and Passing a Jagged Array

I have thoroughly researched this topic and have yet to find code that works to accomplish what I need to do. In a nutshell, I'm creating a Production Tracking program and the feature of it on which I'm working now involves accurately tracking vacation days for 5 employees. A userform containing 5 listboxes, one for each employee, is used to select which days each employee took off for the week. The problem comes when I try to create unique dynamic arrays containing each employees' days off. I figured out how to create an array that captures this information but it's one array that gets reassigned each time the loop iterates. I need to have a unique array for each employee containing his days off to be used later in the code to adjust weekly scoring depending on his available days of work. Below is my code in the userform for to create a create the jagged array:
Public Name_Jagged() As Variant
For Each Name In Name_Array
Set Unique_Listbox = Controls(Name & "_Vacation")
For UnSelected = 0 To Unique_Listbox.ListCount - 1
If Unique_Listbox.Selected(UnSelected) = False Then
ReDim Preserve Name_Jagged(0 To UBound(Name_Jagged) + 1)
Name_Array(Name) = Name_Jagged()
Name_Jagged(UBound(Name_Jagged)) = Unique_Listbox.List(UnSelected)
End If
For UnSelected_Array_Pos = LBound(Name_Jagged) To UBound(Name_Jagged)
MsgBox Name & "_" & Name_Jagged(UnSelected_Array_Pos)
Next UnSelected_Array_Pos
Next UnSelected
Next Name
The compiler will not allow me to use Public Name_Jagged()() As Variant either despite most other forums saying this is how it's supposed to be written. The only other post I found online regarding this jagged array declaration issue was not answered.
I would really appreciate your help. I've been able to figure out everything so far from previous threads but this has eluded me. If there is a better option than jagged arrays to accomplish this, I'm all ears. I read in some forums about using Lists but I am not at all familiar with them or how to use them at this point. Thanks in advance for the help.
Just a thought but why have 5 static listboxes for each employee?
Why not just have 1 list box which contains the names of the employees and 1 list box which contains the days of the week. You highlight the employee you want and than select the days which they've taken off. Hit a submit button which would load the employees name into an array with the days selected? The array could be structured like this
NAME | MONDAY | TUESDAY | WEDNESDAY | THURSDAY | FRIDAY | SATURDAY | SUNDAY
JIM..... OFF............ OFF
ERIC.......................OFF.............OFF
And so on. This way if you need to add people in the future you just add them to the list box. You would than have one simple array to deal with?
Also you said "to be used later in the code to adjust weekly scoring depending on his available days of work"
A suggestion; You may want to consider logging it to a simple mysql/mssql database which gives you far more flexibility and control for the future.