Jump to content
Macro Express Forums

acantor

Members
  • Posts

    1,578
  • Joined

  • Last visited

  • Days Won

    21

acantor last won the day on August 17

acantor had the most liked content!

1 Follower

Contact Methods

  • Website URL
    www.cantoraccess.com
  • ICQ
    0

Profile Information

  • Location
    Toronto

Recent Profile Visitors

1,386 profile views

acantor's Achievements

  1. It happens all the time: Macro Express novices use this forum to ask questions when they get stuck. Even intermediate and advanced level Macro Express people sometimes need help, and ask, too. So yes, check out the Sample macros. Or search the forum for old postings about the specific problem you're having. Or feel free to pose questions.
  2. The following approach is supported by Macro Express, but it will only be reliable if the screen size, screen resolution, and program configuration are fixed. Otherwise, it can probably be made to work by tweaking the values before using the macros. When creating a Macro Express script, choose "Mouse Event" as activation. Provide the coordinates of a square that corresponds to the position of a button with respect to the window. For example, the region (0,0) - (30,30) is a 30 x 30 pixel square in the upper-left corner of the window. Then check the pixel colour. Make sure the macro is application (or window) specific to prevent activation of the script when using other programs. Repeat for every button. If the buttons happen to be side-by-side, consider using the coordinates of the rectangle that corresponds to the position of the group of buttons, and then checking the pixel colour to determine which button was clicked.
  3. Glad the macro is now working. Trial-and-error experimentation is the only way I know to make Macro Express scripts run reliably. I don't think it's possible for a macro to do exactly what it's supposed to do 100% of the time. For example, a macro might fail if a window inexplicibly gains or loses focus the moment after a macro is triggered. But 99% is achievable.
  4. Another way to select a range of cells is to move to the first cell. Press F8 to turn on "Select" mode. Then use Right, Left, Up, and Down to select cells one at a time. In pseudo-code: // Go to cell B12 {F5} // Slight pause B12{Enter} // Slight pause // Select right four cells, and select down four cells {F8} {Right}{Right}{Right}{Down}{Down}{Down} // Number of repeats = the number of cells minus one // Copy the range {Ctrl}c
  5. I modified my script to "manually" split the string at Tab characters. This probably is not the most efficient or elegant way to split a string, but it seems to work... so far! // Define Tab character Variable Set to ASCII Char 9 to %Tab% // Cancel edit mode. Go to start of row. Select right to the first blank cell. Copy it. Text Type (Simulate Keystrokes): <ESC><HOME> Text Type (Simulate Keystrokes): <CONTROL><SHIFT><ARROW RIGHT> Text Type (Simulate Keystrokes): <CONTROL>c // Assign clipboard to variable %Clip%. Variable Set String %Clip% from the clipboard contents Variable Set String %Clip% to "%Clip%%Tab%" // The last cell in a range does not end in a Tab. So add one! // "Manually" split %Clip% at tabs into array %Results% Variable Set Integer %Count% to 1 Repeat Until %Clip% Does not Contain "%Tab%" Variable Set Integer %CharCount% to the position of "%Tab%" in %Clip% Variable Modify String: Copy part of text in %Clip% starting at 1 and %CharCount% characters long to %Results[%Count%]% Variable Modify String %Results[%Count%]%: Trim Text Box Display: Checking results... Variable Modify String: Delete part of text from %Clip% starting at 1 and %CharCount% characters long Variable Modify Integer %Count%: Increment End Repeat <COMMENT Value="Define Tab character"/> <VARIABLE SET TO ASCII CHAR Value="9" Destination="%Tab%"/> <COMMENT/> <COMMENT Value="Cancel edit mode. Go to start of row. Select right to the first blank cell. Copy it."/> <TEXT TYPE Action="0" Text="<ESC><HOME>"/> <TEXT TYPE Action="0" Text="<CONTROL><SHIFT><ARROW RIGHT>"/> <TEXT TYPE Action="0" Text="<CONTROL>c"/> <COMMENT/> <COMMENT Value="Assign clipboard to variable %Clip%."/> <VARIABLE SET STRING Option="\x02" Destination="%Clip%" NoEmbeddedVars="FALSE"/> <VARIABLE SET STRING Option="\x00" Destination="%Clip%" Value="%Clip%%Tab%" NoEmbeddedVars="FALSE" _COMMENT="The last cell in a range does not end in a Tab. So add one!"/> <COMMENT/> <COMMENT Value="\"Manually\" split %Clip% at tabs into array %Results%"/> <VARIABLE SET INTEGER Option="\x00" Destination="%Count%" Value="1"/> <REPEAT UNTIL Variable="%Clip%" Condition="\x07" Value="%Tab%"/> <VARIABLE SET INTEGER Option="\x0E" Destination="%CharCount%" Text_Variable="%Clip%" Text="%Tab%" Ignore_Case="FALSE"/> <VARIABLE MODIFY STRING Option="\x09" Destination="%Results[%Count%]%" Variable="%Clip%" Start="1" Count="%CharCount%" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x00" Destination="%Results[%Count%]%"/> <COMMENT/> <TEXT BOX DISPLAY Title="Checking results..." Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\lang4105\\f0\\fs20 Clip = [%Clip%]\r\n\\par CharCount = [%CharCount%]\r\n\\par Count = [%Count%]\r\n\\par Results = [%Results[%Count%]%]\\lang1033\\f1\\fs14 \r\n\\par }\r\n" Left="821" Top="432" Width="970" Height="449" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> <VARIABLE MODIFY STRING Option="\x0A" Destination="%Clip%" Start="1" Count="%CharCount%"/> <VARIABLE MODIFY INTEGER Option="\x07" Destination="%Count%"/> <END REPEAT/>
  6. Here's a script that selects a range of cells along a row, copies the range to the clipboard, assigns the clipboard to a variable, splits the values into an array, and then displays the first ten cell values. For testing, I manually placed the cursor in the leftmost cell of the range. But the cell shouldn't be in Edit mode. Initially, I had delays after the steps. But with testing, the macro seemed to work without delays. // Define Tab character Variable Set to ASCII Char 9 to %Tab% // Select right to the first blank cell. Copy it. Text Type (Simulate Keystrokes): <CONTROL><SHIFT><ARROW RIGHT> Text Type (Simulate Keystrokes): <CONTROL>c // Assign clipboard to variable %Clip%. Split %Clip% at tabs into array %Results% Variable Set String %Clip% from the clipboard contents Split String "%Clip%" on "%Tab%" into %Results%, starting at 1 // Display first ten cells Repeat Start (Repeat 10 times) Text Box Display: Cell %Count% End Repeat <COMMENT Value="Define Tab character"/> <VARIABLE SET TO ASCII CHAR Value="9" Destination="%Tab%"/> <COMMENT/> <COMMENT Value="Select right to the first blank cell. Copy it."/> <TEXT TYPE Action="0" Text="<CONTROL><SHIFT><ARROW RIGHT>"/> <TEXT TYPE Action="0" Text="<CONTROL>c"/> <COMMENT/> <COMMENT Value="Assign clipboard to variable %Clip%. Split %Clip% at tabs into array %Results%"/> <VARIABLE SET STRING Option="\x02" Destination="%Clip%" NoEmbeddedVars="FALSE"/> <SPLIT STRING Source="%Clip%" SplitChar="%Tab%" Dest="%Results%" Index="1"/> <COMMENT/> <COMMENT Value="Display first ten cells"/> <REPEAT START Start="1" Step="1" Count="10" Save="TRUE" Variable="%Count%"/> <TEXT BOX DISPLAY Title="Cell %Count%" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs32 [%Results[%Count%]%]\\fs14 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> <END REPEAT/>
  7. I've seen the identical message on other sites, and when I've encountered it, I think the checkbox has focus. And if the checkbox has focus, press the space bar to check it. However, if the checkbox doesn't have focus, press Tab until it gains focus. You may need to press it once, twice, ten times. Case by case! Once focus reaches the checkbox, press the space bar. Variation: press Shift + Tab instead of Tab to move focus in the opposite direction. There are other methods that are more challenging to script. But try these simpler solutions first.
  8. I agree with all the earlier comments and suggestions, and especially rberq's idea of selecting an entire row, copying it, assigning the clipboard to a variable, and parsing it. To this end, here are Excel keyboard shortcuts that might be helpful: Shift + Right Arrow = select cell to the right. Shift + Right Arrow repeated = repeatedly select cells to the right. Shift + Ctrl + Right Arrow = select a range of cells to the right, until a blank cell is encountered or the end of the row. Shift + Space Bar = select the entire row.
  9. It's an excellent question. You probably will need to modify security settings in Word to run VBA scripts. In Word 2019, I changed this setting: File > More... > Options > Trust Center > Trust Center Settings... > Macro Settings > Enable all macros Be cognizant of the risks of enabling Word macros. I consider the risks minimal, with benefits outweighing risks. But different people have different risk tolerances. My perspective is that any kind of macro system opens a door to vulnerabilities: It doesn't matter whether the system is VBA, Macro Express, AutoHotkey, Dragon Advanced Scripting, MacroWorks, or any other macro scripting tool. If someone intends to hack into a system, macros make their job a little easier. BTW, I'm aware of two security-obsessed financial sector organizations that have certified Macro Express for employee's use. I guess they consider Macro Express safe! I'm also aware of other security-obsessed organizations that deploy VBA Word macros for their employees.
  10. Or this? <VARIABLE SET INTEGER Option="\x01" Destination="%MinValue%" Prompt="What is the minimum value?" Mask="FALSE" OnTop="TRUE" Left="Center" Top="Center" Monitor="0" Lines="\x00"/> <VARIABLE SET INTEGER Option="\x01" Destination="%MaxValue%" Prompt="What is the maximum value?" Mask="FALSE" OnTop="TRUE" Left="Center" Top="Center" Monitor="0" Lines="\x00"/> <COMMENT/> <VARIABLE MODIFY INTEGER Option="\x01" Destination="%NumberOfRepeats%" Value1="%MaxValue%" Value2="%MinValue%"/> <REPEAT START Start="1" Step="1" Count="%NumberOfRepeats%" Save="FALSE"/> <COMMENT Value="Do something"/> <END REPEAT/> <COMMENT/> Variable Set Integer %MinValue%: Prompt Variable Set Integer %MaxValue%: Prompt Variable Modify Integer: %NumberOfRepeats% = %MaxValue% - %MinValue% Repeat Start (Repeat %NumberOfRepeats% times) // Do something End Repeat
  11. Maybe something like this? <MULTIPLE CHOICE MENU Style="\x00" Result="\x00" Dest="%Choice%" Title="Choose a value" Prompt="Here are the choices" Options="12760\r\n12761\r\n12762\r\n12763\r\n12764\r\n12765\r\n12766\r\n12767\r\n12768\r\n12769\r\n12770\r\n12771\r\n12772\r\n12773\r\n12774\r\n12775\r\n12776\r\n12777\r\n12778\r\n\r\n1277" Left="727" Top="341" Monitor="0" Width="506" Height="465" OnTop="TRUE" Columns="Auto"/>
  12. Hi Mark, Congratulations on persevering and coming up with a Macro Express solution! VBA is a universe unto itself. My tendency, when automating tasks in Word, is to use Macro Express when I need quick solutions, and VBA when more complex solutions are needed to get the job done quickly. But there are exceptions. One of my most complex macros for Word, which I use dozens or hundreds of times a day, works best as a Macro Express script. With VBA, it's possible to write one macro that performs two different actions, depending on the font colour of the current selection. In this example, the macro checks the existing font colour. If it's red, the macro changes it to green. If the font colour is anything other than red, the macro changes it to red. The second last line of code makes the selection bold. Sub RedOrGreenBold() If Selection.Font.Color = wdColorRed Then Selection.Font.Color = wdColorGreen Else Selection.Font.Color = wdColorRed End If Selection.Font.Bold = True End Sub
  13. I agree with Cory. This is best accomplished via VBA. VBA is the macro language built into Word. To access VBA editor, press Alt + F11. Look online to learn how to create a procedure. Then use the following code as the procedure: Sub GreenBold() With Selection.Font .Color = wdColorGreen .Bold = True End With End Sub Also online, you'll find instructions for assigning a hotkey to "GreenBold," which will make it easy to access. You can also add GreenBold to the Quick Access Toolbar.
  14. You could try to add a little logic to your script. Not sure whether the macro will need to capture the total number of monitors connected to your computer, the number of the active monitor, or both values. Time for some trial-and-error experimentation! Variable Set Integer %MonitorActive%: Set to Active Monitor Variable Set Integer %MonitorCount%: Set to Number of Monitors Text Box Display: Number of monitors = %MonitorCount% Active monitor = %MonitorActive% Switch( %MonitorCount% ) Case: 1 // Do something if this is Monitor 1 End Case Case: 2 // Do something else if this is Monitor 2 End Case Default Case // And do something else if this is not Monitor 1 or 2! End Case End Switch
  15. Sure. Text Type (Simulate Keystrokes): <SHIFTD> Mouse Move: 100, 100 Relative to Last Position Text Type (Simulate Keystrokes): <SHIFTU>
×
×
  • Create New...