Hi I'm using Applescript to enter text on a Safari Webpage.
One of the fields is a phone number that gets formatted with parenthesis as the user (human being) enters the numbers.
For instance if the user enters
123456789
the field ends up looking like this
(12)3456789
For some reason when the same numbers are "entered" by my script they do not get formatted, even though they are exactly the same.
The script is quite simple
if Celular is not "" then
keystroke Celular
delay tiempo
end if
Any hint of what can I be doing wrong?
Many thanks in advance
Two options to try, are first, tab out of the field using a key code.
tell application "System Events"
if Celular is not "" then
keystroke Celular
delay tiempo
key code 48 -- a tab
end if
end
Alternately, you might try formatting the number yourself first:
set Celular to "5558675309"
set Celular to "(" & (text 1 thru 3 of Celular) & ") " & (text 4 thru 6 of Celular) & "-" & (text 7 thru 10 of Celular)
Related
I have a sheet that has a few hundred drop down boxes. I want a button that resets them all to the null or top value when clicked. I can get it to work for individual drop downs but I can't get the syntax right to loop through a group of them. I've tried everything I can think of to append "i" onto "Drop Down" but can't get it to work.
This works fine, I don't want to write this a few hundred times:
ThisWorkbook.Sheets("sheet1").Shapes("Drop Down 260").ControlFormat.Value = 1
How do I get this to work:
For i = 1 To 260
ThisWorkbook.Sheets("sheet1").Shapes("Drop Down & i").ControlFormat.Value = 1
Next i
I've tried ("Drop Down" & " " & "i"), ("Drop Down" & " " & i), and everything else I could think of. I've exhausted Google and can't figure it out.
I have run into a weird issue.
I have assigned a string value to the list of a combobox that includes a unicode character. In my case, these are triangles up/down (ChrW(&H25B2) = ▲ & ChrW(&H25BC) = ▼) to denote the ASC/DESC of the desired data sort.
Now, the problem is that Excel successfully displays the unicode character in the combobox only when the control is active (when I select or click on it). BUT, when I click away from the control or change focus it displays a question mark (?), as if I am trying to display an unknown character. The character always displays properly inside of a cell, but not a combobox. I was thinking that maybe two different fonts are being displayed depending on active status, but this has not been set, and I see no option for this in the properties. I also tried the decimal method for adding the characters (ChrW(9660) & ChrW(9650)), just in case, but that didn't change anything
What is going on here? How can I have ▲ & ▼ always display properly.
EDIT: Having learned that VBA controls are limited to ANSI characters, and can't display Unicode characters, Is there a way to display the triangles like I want despite ANSI not having triangles or up/down arrows in its character set?
See code and image below to see what I mean.
Sub PopulateSortList()
'Populate Sort Dropdown control
With Sheet1.ComboBox_Sort
.Clear
.AddItem "Time - IN " & ChrW(&H25B2) 'Ascending
.AddItem "Time - IN " & ChrW(&H25BC) 'Decending
.AddItem "Time - OUT " & ChrW(&H25B2) 'Ascending
.AddItem "Time - OUT " & ChrW(&H25BC) 'Decending
.Font.Size = 11
.TextAlign = fmTextAlignLeft
.SelectionMargin = False
.ListIndex = 1
End With
End Sub
I have a lot of sensoric measurements in my excel table and some one are unreal, so i want to delete them. For that i wrote a code and it works good, but the "Motorlast" makes some Problems. Every measurement format is a "text"-format.
my problem is that a number which should be less 100 is greater 100.
See code...
Private Sub TestButton_Click()
' ist der TestButton
spalte = 16
anzahlZeilen = ActiveSheet.Range("A40000").End(xlUp).Row
vergleichswert = 100
If ActiveSheet.Cells(4, spalte) > vergleichswert Then
MsgBox "Zahl " & ActiveSheet.Cells(4, spalte) & " > Vergleichswert " & vergleichswert
Else
MsgBox "is kleiner"
End If
End Sub
It should not be possible that i come into the if condition, but i do and i don't know why :D Do you have any suggestion?
Image 1 from Excel
Image 2 from Excel
From the code sample, it looks like this might be running on a computer using the German language. This could affect how numbers are interpreted. In US English, a period would indicate the decimal separator, but in German a period could be used for digit grouping. Depending on the locale settings of the computer, this could impact how the expression is being evaluated.
For example, in the English locale, "41,18">100=True but "41.18">100=False
If this is what is happening, you could use the replace function to swap the period for a comma. This might solve your problem.
If Replace(ActiveSheet.Cells(4, spalte),".",",") > vergleichswert Then
I am trying to generate a customer number using the first three letters of the customers last name, the first name initial and middle initial, followed by the last four of their phone number. How would I do this? All I need is the formula.
First_Name Middle_Initial Last_Name Street_Address City State Zip Phone
Nathaniel E. Conn 6196 View Ct Lancing TN 37770 567-273-3956
Something like this (assuming a table with [structured-references], fill in the actual cell names if not):
=LEFT([LastName] & "---", 3)
& LEFT([FirstName] & "-", 1)
& LEFT([MiddleInitial] & "-", 1)
& RIGHT([PhoneNumber] & "----", 4)
I have used dashes ("-") to fill in any spaces where the field might be smaller than the number of characters you need from it. You can change them to any fill character that suits you.
Well, it depends on if each piece of data has its own column, looks like it does.
You can use the left/right functions to parse the data out of your columns.
=CONCATENATE(RIGHT(C1,3) & LEFT(A1,1) & LEFT(B3,1) & RIGHT(H1,4))
I would do:
=MID(CELL_LAST_NAME;1;3)&MID(CELL_FIRST_NAME;1;1)&MID(CELL_MIDDLE_NAME;1;1)&MID(CELL_PHONE;LEN(CELL_PHONE)-3;4)
I don’t know AppleScript at all so thanks in advance for any help offered on this question.
I’m on my Macbook Pro laptop with the latest version of OSX installed. I have an Excel spreadsheet (I could use numbers if that makes it easier) with two columns.
FirstName Email
------------ -----------------
Ken blah#blah.com
Mike blahblah#blahblah.com
This is my customer list and I want to send them an email. Unfortunately I don’t have this list in an autoresponder so I have to send the emails one by one.
I know that I could whip up a PHP script to send the emails, however there are issues with email deliverability when doing it this way.
I want to write an AppleScript that processes my spreadsheet one row at a time and sends a message.
The message would be something like this:
Subject: How’s it going?
Hi Ken
It’s been a while since I sold you that defective widget from China.
If you need more defective elctronics I’m here for you. Just give me
a call at xxx-xxx-xxxx.
Sincerely
Ken
The AppleScript would read the name and email address from one row of the spreadsheet and send this email, filling in name and email address, using the standard apple mail program.
After sending the message I want the script to wait 60 seconds. Then send another email.
This needs to happen until a blank row is encountered.
My first question… Is this possible? If possible how do I do it?
Also is there a better way to do what I’m trying to do?
Thanks
There's probably a better way to do this, but couldn't you just copy the addresses as TSV or CSV?
set addresses to "Ken;blah#blah.com
Mike;blahblah#blahblah.com"
set text item delimiters to ";"
repeat with l in paragraphs of addresses
tell application "Mail"
tell (make new outgoing message)
set subject to "subject"
set content to "Hi " & text item 1 of l & linefeed & linefeed & "..."
make new to recipient at end of to recipients with properties {name:text item 1 of l, address:text item 2 of l}
send
delay (random number) * 100
end tell
end tell
end repeat
Try:
set {firstName, eAddress} to getData()
repeat with i from 1 to count firstName
tell application "Mail"
activate
set mymail to make new outgoing message at the beginning of outgoing messages with properties {subject:"How’s it going?"}
tell mymail
make new to recipient at beginning of to recipients with properties {address:item i of eAddress}
set content to "Hi " & item i of firstName & "
It’s been a while since I sold you that defective widget from China.
If you need more defective elctronics I’m here for you. Just give me
a call at xxx-xxx-xxxx.
Sincerely
Ken"
end tell
--show message window (otherwise it's hidden)
set visible of mymail to true
--bring Mail to front
activate
send mymail
end tell
end repeat
on getData()
set colA to {}
set colB to {}
tell application "Microsoft Excel"
activate
tell active sheet
set lastRow to first row index of (get end (last cell of column 1) direction toward the top)
repeat with i from 3 to lastRow
set end of colA to (value of range ("A" & i))
set end of colB to (value of range ("B" & i))
end repeat
end tell
end tell
return {colA, colB}
end getData