Python Forum
Auto-populate Macro variables
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Auto-populate Macro variables
#1
I've been assigned the task of looking up master routing information for a part number, and changing the assigned Purchase Requisition information from one that is outdated to a new number. This number will be something of the variety 200003215, and unique to each new part number I look up. I will be given this information in a spreadsheet. For similar tasks I use a Python program my colleagues and I have dubbed 'hotstrings.' It is essentially a simple macro program:

import ctypes
ctypes.windll.kernel32.SetConsoleTitleW("Hotstring")
import keyboard as k

h = k.add_abbreviation

h('.A',"APPLE")
h('.B',"BANNANA")
h('.C',"CARROT")
h('.D',"AVOCADO")

You can set up this script to allow you to type a character string, and it prints what ever is in the quotations for you. E.G. typing .A will print Apple in the active field and window you are using. This is useful for tasks requiring the same part number to be put into multiple fields in the ERP system, quickly and efficiently without error. However, I plan to use if for more part numbers than I ever have before, setting it up manually like I usually do would be time consuming.

My question is, is there a way to import a text file or spreadsheet containing the part numbers, and have them automatically enumerate? And I realize enumerating isn't really what I want to do anyway, more I want to have a character sting automatically assigned to each part number. Additionally, the total number of part numbers will be more than 26, if I am able do this, how would I tell it to start over with '.AA','.BB','CC.' ect. when the time comes?

I'm NOT wanting to automate and a find and replace system, I want to retain control over each transaction, but still save time by not having to type each part number in full.

I'm very new to Coding in general and Python in particular, I'm not even sure what questions I should be asking, I hope I've been clear enough to at least get pointed in the right direction.
Reply
#2
The answer to all your questions is yes. This is a good beginner python coding project. You also clearly took a lot of care in writing your question. I'm sure we all appreciate it. You seem to have your head around things, but don't know the python to express it.

Every question you asked, has a basic python answer. But we need to start at the being. Can you make a window? or does your keyboard run in a python terminal? Let me know what you know so we can identify a good next step.
Reply
#3
My experience level is probably best described as 'user,' I edit an exiting script that was wrote and saved by someone else, But I haven't tried to make one of my own from scratch yet.

My current process is to edit the code in IDLE 3.9.1 (64-bit), then run the module in IDLE Shell 3.9.1

It stays open in the background, and then when I use one of the shortcut strings in a word file or our ERP system it fills with the defined text.

I would attach a screen shot but I can't figure out how.
Reply
#4
Ive thought a lot about it, and I think I see a vision of what I should do. You guys tell me if im on the right track, or being silly, or if there's a mich better way that be great. And keep in mind I probably won't know how to do any of this yet, but I think what needs to happen is thus:
-make an excel file that contains a list of part numbers in column A.
-make column B a sequence of upper case letters, A,B,C and so on
-column C is a list of the new purchase order requisitions ill be update that corrospond to the part numbers in column A
-Column D is a series of sequential numbers, 1,2,3 ect
-import the spreadsheet to the python code
-tell it to make column A equal column B for each row, and the same for column c to column D.
From there the macro should work for typing an 'A' you get the part number from row 1 column a, and typing a '1' gives you row 1 for column c
Youd think so anyway. Any thoughts or feelings are welcome.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how to populate a dataframe thru line iteration ? knob 0 975 May-05-2022, 12:48 AM
Last Post: knob
Question convert autohotkey script to python / macro - press key when pixel get colour willson94d 1 3,572 Jan-01-2022, 08:13 PM
Last Post: Yoriz
  Populate Dropdown list from Database TommyAutomagically 4 4,347 Nov-02-2021, 05:23 PM
Last Post: ndc85430
  Python3 doesn't populate xlsx file with openpyxl Auldyin75 2 2,488 Feb-16-2021, 12:00 PM
Last Post: Auldyin75
  create new tabs and populate using python reggie4 2 2,218 Jan-23-2021, 11:25 PM
Last Post: Larz60+
  Populate a table with variables Market_Python 4 2,509 Jan-11-2021, 09:45 AM
Last Post: Pedroski55
  How do I reduce the time to Invoke Macro via Python? JaneTan 1 2,074 Dec-28-2020, 06:46 AM
Last Post: buran
  Hi Guys, please help me to write SAS macro parameter equivalent code in Python Manohar9589 2 2,537 Jun-14-2020, 05:07 PM
Last Post: Larz60+
  Jython macro which uses PythonInterpreter and Redis script gives an error rkanumola 2 2,205 Oct-30-2019, 07:37 AM
Last Post: rkanumola
  run an excel macro with python mmolet 1 8,953 Apr-02-2019, 09:36 AM
Last Post: Vinci141

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020