Hotkey for mail merge record delimiters in word

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
vksasingh
Posts: 2
Joined: 25 Feb 2018, 15:15

Hotkey for mail merge record delimiters in word

25 Feb 2018, 15:46

Hi there, I am new to AHK. Need help with this - I want to create a hotkey for below:
Image

the above is the mail merge window, opened in word when data source selected is another word-document/file.

I am trying to set the field-delimter as , and the record-delimiter as ^.

I have tried something like:

Code: Select all

#EscapeChar \
j::
SendInput, \,
SendInput, {TAB}
Send, {Asc 94}
Return
But it's not working.. I tried with

Code: Select all

#EscapeChar \
j::
SendInput, \,
SendInput, {TAB}
Send, {^}
Send, {TAB}
Return
again to no avail. Can someone please guide what i am missing or how it can be done?
User avatar
Jovannb
Posts: 268
Joined: 17 Jun 2014, 02:44
Location: Austria

Re: Hotkey for mail merge record delimiters in word

25 Feb 2018, 16:23

Hi

use VBA-Macro recorder to identify relevant programming elements in Winword.

Then you can build your AHK script (by using COM).

JB
AHK: 1.1.37.01 Ansi, 32-Bit; Win10 22H2 64 bit, german
vksasingh
Posts: 2
Joined: 25 Feb 2018, 15:15

Re: Hotkey for mail merge record delimiters in word

27 Feb 2018, 09:51

Hi JB, I tried the recorder, these are the elements that the vb code shows:
ActiveDocument.MailMerge.OpenDataSource and .MailMerge.destination = wdSendToNewDocument

I am not sure how to use these and how COM can help?
User avatar
FanaticGuru
Posts: 1906
Joined: 30 Sep 2013, 22:25

Re: Hotkey for mail merge record delimiters in word

27 Feb 2018, 13:31

vksasingh wrote:Hi JB, I tried the recorder, these are the elements that the vb code shows:
ActiveDocument.MailMerge.OpenDataSource and .MailMerge.destination = wdSendToNewDocument

I am not sure how to use these and how COM can help?
If you post the entire recorded macro I can probably help convert to AHK COM.

If you can create a macro that does entirely what you want then AHK will in most cases be able to do everything that your macro does and more.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
User avatar
Jovannb
Posts: 268
Joined: 17 Jun 2014, 02:44
Location: Austria

Re: Hotkey for mail merge record delimiters in word

27 Feb 2018, 14:04

Hi,

I tried a little to translate your VBA-Code, that works half, try it it opens a dialog box in Word with that XLSX-Files - stepping trough with SciTE4AHK (F7 & F10) eg.:

Code: Select all

#SingleInstance force

Word := ComObjActive("Word.Application") ; you need an opened Winword-document

;VBA:ActiveDocument.MailMerge.OpenDataSource and .MailMerge.destination = wdSendToNewDocument

; Opendatasource and its parameters:
; https://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.mailmerge.opendatasource.aspx

; wdopenformat enumeration:
; https://msdn.microsoft.com/en-us/vba/word-vba/articles/wdopenformat-enumeration-word

datasource1:="n:\joma\data.xlsx"
wdOpenFormatAuto:=0
word.ActiveDocument.MailMerge.OpenDataSource(datasource1,wdOpenFormatAuto,0)

return

Check those links in my AHK-Comments as well, and then you have to try to understand how to use all those parameters available for OpenDatenSource

J.B.
AHK: 1.1.37.01 Ansi, 32-Bit; Win10 22H2 64 bit, german

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 207 guests