Date cannot be pasted on chrome with using VBA - Selenium - excel

I can change date on web page if I use internet explorer with below code(code1).
however, I changed browser to chrome with selenium. (as code 2), date section on web page is changed but it is partial.
for example: date is set 18/02/2020 on web page when it is opened. then I want to change date as 01/03/2017 but it is changed to 03/02/2017. that means, month section in macro shanged the date section, nothing changed on month section and year section is also changed
i have tried to change date order in macro like mm/dd/yyyy but ı cant get a proper date solution. just tried millions of code and still cannot find anything.
so please help me to change date section on chrome with using selenium.
Sheet1.Range("A1") = 01/03/2017
Code1
ie.document.getElementsByName("date$From")(0).Value = Sheet1.Range("A1").Text
Code2 (selenium and VBA)
obj.FindElementById("date_From").SendKeys (sheet1.Range("A1")).Text
Website code (website is behind a firewall)
<input name="date$From" type="text" value="18/02/2020" size="6" id="date_tbFrom" class="searchSelect">
<input type="hidden" name="date_From_Client" id="date_From_Client">

found a solution bymelf with try it. I used tab button usage to reach date section and used date format as 01,01,2021. used comma (,) instead of slash (/) as date seperator.
obj.FindElementByName("date$From").Clear
obj.FindElementById("place_before_date").Click
obj.SendKeys (keys.Tab)
obj.FindElementById("date$From").SendKeys (Sheet1.Range("A" & x))

Related

Is there a way to use VBA to change the language in VBA generated worksheets?

I was assigned a project at work to develop a Macro that would automatically take financial data from an Excel table and generate credit notes and invoices for customers. I have the Macro developed already it is working the way it should, but the issue I am running into is with the language that is used for each invoice.
When generating credit notes, the Macro is taking the the invoices month of issue from the financial data table and displaying then as them as the months where credit was issued to the customer. i.e., a customer is requesting a partial refund on transactions from a period of time (say Feb.2019 - Apr. 2019) it will be displayed as:
February 2019 (02-19) -20.20
March 2019 (03-19) -32.03
April 2019 (04-19) -24.21
The problem is that my primary working language is English, but my company works in several European marketplaces and the invoices and credit notes have to be displayed in the language of the market where the customer is located.
So if an Italian customer requests an invoice, the months displayed must be listed as
Febbraio 2019 (02-19) -20.20
Marzo 2019 (03-19) -32.03
Aprile 2019 (04-19) -24.21
However, when running the Macro it still displays the issuing months in English when it should be displayed in the language of the market. The entirety of all invoices and credit notes created with this Macro are generated in the correct language, but since the Macro is taking the issuing months from the data table it automatically displays them in English.
Is the any way to ensure that it displays the issuing months in the required language?
I already know that the language settings can be changed for the entire workbook, but I still run into the same problem as I would have to manually change the issuing language each time I run the Macro to ensure the issuing month is correct?
To format a date in another regional setting you need to change the number format of the date for the desired range of cells. Eg. format the cell pressing Ctrl+1 to get the following dialog, and choose the regional setting ("Gebietsschema") for the country you desire.
Image 1: Change the regional setting for the date (sorry for the German screenshot).
Alternatively use the Range.NumberFormat property to format the cell with VBA:
.NumberFormat = "[$-it-IT]d mmmm yyyy;#"
Note that these both work if your dates are real date values but don't work if your dates are text. If they are text you need to change them into real dates.

How to get English month name from date in Russian Excel?

I am unable to get month name in Excel.
Neither =TEXT(...;"mmmm") not doesn't work.
I found, only Russian M's are working and giving Russian month name, despite of language settings
Latin M's give nothing.
Are there any other settings to force month name language?
UPDATE
Setting date format nationality didn't help:
Thanks for additional details. It appears to be a long standing issue with MS Office. See How to prevent Excel to use the OS regional settings for date patterns in formulas for a related issue and some partial solutions.
In particular, hardcoding using CHOOSE might be your way to go:
=CHOOSE(MONTH(B2);"Jan";"Feb";"Mar";"Apr";"May";"Jun";"Jul";"Aug";"Sep";"Oct";"Nov";"Dec")
Also see Scott Craner's comment regarding =TEXT(B2;"[$-0409]MMMM") which looks like a quick fix. But note that the MMMM has to be in your locale, so the spreadsheet might not be portable. The CHOOSE option would be better in this case.
I found a way to fix this problem. First you need to go to Excel options and click "Advanced". After that, you need to scroll down to the bottom of this page and edit the "Edit Custom Lists..." button located in the "General" tab. Image for first step
Finally, you should add your own lists by clicking NEW LIST.
Image for final steps
January
February
March
April
May
June
July
August
September
October
November
December

Excel doesn't show value as date although indicated with VT_DATE and using SystemTimeToVariantTime

we are exporting to excel (office2010) via COM automation (C++).
Meaning we use SafeArrays, VARIANTs and the use the excel API like range->PutValue().
We have an issue on certain (not all) customer machines with exporting date values.
We normally indicate the value of the VARIANT as VT_DATE and fill in the date member.
Something like this:
VARIANT vValue;
SYSTEMTIME SystemTimeVal;
short Year=2011;
short Month=11;
short Day=14;
short Hour=0;
short Minute=0;
short Second=0;
SystemTimeVal.wYear = (WORD)Year;
SystemTimeVal.wMonth = (WORD)Month;
SystemTimeVal.wDay = (WORD)Day;
SystemTimeVal.wHour = (WORD)Hour;
SystemTimeVal.wMinute = (WORD)Minute;
SystemTimeVal.wSecond = (WORD)Second;
V_VT(&vValue) = VT_DATE;
SystemTimeToVariantTime(&SystemTimeVal, &(vValue.date));
// SafeArrayPutElement related code omitted here
pRange->PutValue(variantContainingSafeArray);
// ...
When opening the xls file, the value shown is as a number.
If you open Format dialog in Excel, it should "General".
In this case the number is 40861.
When letting Excel format it as Date, the correct date 14 november 2011 is shown.
On my pc and at other customers, Excel nicely formatted it as Date.
The case in which it happened is with a French customer, but colleages have used the same regional settings and language settings, and on their pc every thing goes fine...
Also we have several other French customers and never got a complaint from them.
I suppose it must be some machine specific issue but have no clue...
Did somebody run into the same kind of issue?
Bart
it looks like installing SP1 for Office fixes the problem...

Google Docs Spreadsheet Info for Finance stocks

Im trying to have dividend payable dates, or ex-dividend dates populate in the cell next to a ticker. Anyone ever done this? Does not seem I can find this one.
If you are able to find a web page that provides this information based on a given ticker, you can use importXml function in the spreadsheet.
This function gets the URL of the site (probably with some query as q=TICKER), and XPATH expression of the field with the relevant value.
You can find the XPATH using "Inspect Elemnt" in Chrome, Safari and other modern browsers.

How to get the Current Date & Time Automatically to a Date Time Field

I have created a date time field I made today's date as the default value, Then I added it to a page layout and created a page, But the current Date Time is not picking up from the system.
I dont want to give the user to select a Date Time instead it should populated automatically
Is there anyway to achieve this without writing code in code behind files?
This is very similar to this question I think
SO - How to get Date and current time from the Date/Time column in SharePoint Custom list
My answer there gives a few options such as using the built in Created field, using a calendar template, a JavaScript hack and a custom field type.
Guys, fake [Today] trick worked for us - but prob is we only got the date value not datetime.
Janis, is it possible to get date and time both from the fake [today] column trick? pls refer few articles on the same
Does [Today] work?
If you have language pack applied to SharePoint, then you must use localized "Today" string.

Resources