Using textexpander string "addr1"

Discussion, questions and support.
Post Reply
Marty123
Posts: 25
Joined: Apr 17th, ’22, 23:05

Post by Marty123 » Jun 12th, ’22, 08:57

Hi Folks,

i wish to use a text expander abbrev "addr1" which contains an address, to fill into one of cell (b1)of file "statement.xlsx"
Here's the code.

Code: Select all

Path := "C:\Users\master\Desktop\Statement.xlsx"
ahmen :=ComObjcreate("Excel.Application")
ahmen.visible := True
ahmen.Workbooks.Open(Path)      ;you can "Add" (without the quotation of course) after  
ahmen.Range("B1").Value := "addr1"
especially the last line, i do understand from the answer of a previous post that the abbrev string addr1, cannot be used this way.
I like to reach out and check how i could put the content of addr1 into cell b1 then. Hope to hear from you soon.
User avatar
Marko
Posts: 1718
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Jun 12th, ’22, 09:12

Like this?

Code: Select all

ahmen.Range("B1").Value := "My address"
The substitute string is not saved in a variable so you cannot use it in other scripts. You need to define a variable first, one way would be to use a User Variables. In this case you could do

Code: Select all

ahmen.Range("B1").Value := A_Address
Marty123
Posts: 25
Joined: Apr 17th, ’22, 23:05

Post by Marty123 » Jun 12th, ’22, 09:41

Hi Marko,
I have an excel file which my client populate on their end, and email to me. It consist of his bio info,residence, contact info, etc. There is a total of 20 fields or so. I doubt the user variables has that much entries to spare, but that's beside the point. I then import the excel into text expander for filling up the 3 to 5 pdf files (around 8-15 pages each)and submit to my company to underwrite their application. I find this to save alot of my time cuz i wouldnt need to copy and paste using the clipboard repeatedly. However i like to evolve my workflow to just write a script to populate into the pdf, but the science required behind the script writing is beyond me (let me know if you have a commercial solution that i can pay you guys to have it written) so i retort to request for an excel version of these pdf forms. One company came back to me and provide such excel file. And I have been working wiht the excel to see if i could populate the field by using the above simple script, cell by cell, field by field. I was thinking since the info of my client have been imported into textexpander, (abbrev like name1::Albert Bensom, or addr1::1, sesame streets) i was wondering if i could re-use them to incorporate into the script to write to excel. So that's pretty much my thinking. If there's a shortcut, i would appreciate it, but thanks, Marko, for your lightning respond
User avatar
Marko
Posts: 1718
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Jun 12th, ’22, 13:24

Maybe I was not clear. In the script, you can define any number of variables and then reuse them in this or any other command.

Code: Select all

NameVar:="Albert Bensom"
AddressVar:="1, sesame streets"
;etc

Path := "C:\Users\master\Desktop\Statement.xlsx"
ahmen :=ComObjcreate("Excel.Application")
ahmen.visible := True
ahmen.Workbooks.Open(Path)
ahmen.Range("B1").Value := NameVar
ahmen.Range("B2").Value := AddressVar
Alternatively, you could define all such variables to be run when FastKeys starts - create a Start Menu item, Type: Command, select "Run on Startup" option. Type: Command:

Code: Select all

NameVar:="Albert Bensom"
AddressVar:="1, sesame streets"
;etc
Then use the variables in other scripts wherever needed.
You can also contact me directly via our support mail.
Marty123
Posts: 25
Joined: Apr 17th, ’22, 23:05

Post by Marty123 » Jun 13th, ’22, 04:25

Wow, thanks, I didn't know these variables can be run on start up. That's heartening

Anyway, you've been clear in your previous replies, and I understood.it's just I wanted a way to use those text expander strings since they were already imported and present anyway.

Thanks Marko. As usual thanks for the prompt response
mr9bitbyte
Posts: 21
Joined: Apr 25th, ’23, 17:20

Post by mr9bitbyte » Apr 26th, ’23, 21:10

This information seems really useful!, in comparison the User Variables seems really limited and not really useful. wouldn't it be much better to replace it with a big multiline input window where user can define/declare any number of variables to use throughout any place in the program
mr9bitbyte
Posts: 21
Joined: Apr 25th, ’23, 17:20

Post by mr9bitbyte » Apr 26th, ’23, 22:53

Marko wrote: Jun 12th, ’22, 13:24 Maybe I was not clear. In the script, you can define any number of variables and then reuse them in this or any other command.

Code: Select all

NameVar:="Albert Bensom"
AddressVar:="1, sesame streets"
;etc

Path := "C:\Users\master\Desktop\Statement.xlsx"
ahmen :=ComObjcreate("Excel.Application")
ahmen.visible := True
ahmen.Workbooks.Open(Path)
ahmen.Range("B1").Value := NameVar
ahmen.Range("B2").Value := AddressVar
Alternatively, you could define all such variables to be run when FastKeys starts - create a Start Menu item, Type: Command, select "Run on Startup" option. Type: Command:

Code: Select all

NameVar:="Albert Bensom"
AddressVar:="1, sesame streets"
;etc
Then use the variables in other scripts wherever needed.
You can also contact me directly via our support mail.
I have been trying to delcare some variables to use them in a command but Iw as having some issues. I tried the method that you mentioned start menu and add a command to run on start up, but it didnt work , instead of sending the value of the string inside the variables, the name of the variable was sent : %variable1%.

By "declaring/assigning" these variables in the tools startup script is the only way I was able to do it, but I noticed that the variables would not work unless I named them prefixfig them with "A_".

For instance is tried the examples you gave earlier:

NameVar:="Albert Bensom"
AddressVar:="1, sesame streets"

but would not work unles they were named

A_NameVar:="Albert Bensom"
A_AddressVar:="1, sesame streets".


Is there somewhere in the documantation I can read up more about this topic and understad why variables must be prefixed with A_?
User avatar
Marko
Posts: 1718
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Apr 30th, ’23, 14:39

You are right, only A_ variables are currently recognized. We may improve this in one of the next updates.
mr9bitbyte
Posts: 21
Joined: Apr 25th, ’23, 17:20

Post by mr9bitbyte » May 4th, ’23, 15:45

Marko wrote: Apr 30th, ’23, 14:39 You are right, only A_ variables are currently recognized. We may improve this in one of the next updates.
I think if system variables are prefixed with A_, it would make sense to add a different prefix to user variables, lets say U_ for user variables. It would be great the software would notify you if you were trying to declare a variable that already exists.
Post Reply