473,799 Members | 3,224 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SendKey Commands

I have an issue where I have three Cases that SHOULD act the same but
don't. If you look at the code below you will see that the general
premise is to open a MSWord template and then use SendKey commands to
get it to save the file using a new name (NewFName is assigned earlier
in the code).

A couple of issues to keep in mind. These are MailMerge templates that
are attached to a Text Deliminted File (a separate one for each Case,
i.e. Agent.txt, Client.txt and Sales.txt respectively). The text files
were created in the same manner (exported from an Access query).
Start Code
----------------------------------------------------------
Select Case frmTempType
Case 1 'Agent
intForm = Shell("C:\Progr am Files\Microsoft
Office\Office\W inword.exe " & "C:\TEMP\MailMe rge\NewAgent.do t", 1)
SendKeys "%f" 'Calls up File Menu
SendKeys "a" 'Calls up SAVE AS command
SendKeys NewFName 'Inserts filename into the filename field
SendKeys "{TAB}" 'Tabs to SAVE button
SendKeys "{TAB}"
SendKeys "~" 'Confirms and initiates the save.
Case 2 'Client
intForm = Shell("C:\Progr am Files\Microsoft
Office\Office\W inword.exe " & "C:\TEMP\MailMe rge\NewClient.d ot", 1)
SendKeys "%f" 'Calls up File Menu
SendKeys "a" 'Calls up SAVE AS command
SendKeys NewFName 'Inserts filename into the filename field
SendKeys "{TAB}" 'Tabs to SAVE button
SendKeys "{TAB}"
SendKeys "~" 'Confirms and initiates the save.
Case 3 'Sales
intForm = Shell("C:\Progr am Files\Microsoft
Office\Office\W inword.exe " & "C:\TEMP\MailMe rge\NewSales.do t", 1)
SendKeys "~" 'Confirms the import method of the text
file. Don't know why its not needed on the others.
SendKeys "%f" 'Calls up File Menu
SendKeys "a" 'Calls up SAVE AS command
SendKeys NewFName 'Inserts filename into the filename field
SendKeys "{TAB}" 'Tabs to SAVE button
SendKeys "{TAB}"
SendKeys "~" 'Confirms and initiates the save.
End Select
----------------------------------------------------------
End Code

The problem is that for some reason when the Sales Case (Case 3 above)
is initiated a text conversion box appears when it attempts to open the
file asking for what kind of conversion that I want to perform and for
some reason it doesn't perform the rest of the SendKey commands
correctly. Anyone have any insights on why the SendKey commands would
work fine in Case 1 & 2 but not in Case 3 above?

von

Nov 13 '05 #1
3 24689
Automation is usually a much more flexible way to interact with Word.

<ba*********@sb cglobal.net> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
I have an issue where I have three Cases that SHOULD act the same but
don't. If you look at the code below you will see that the general
premise is to open a MSWord template and then use SendKey commands to
get it to save the file using a new name (NewFName is assigned earlier
in the code).

A couple of issues to keep in mind. These are MailMerge templates that
are attached to a Text Deliminted File (a separate one for each Case,
i.e. Agent.txt, Client.txt and Sales.txt respectively). The text files
were created in the same manner (exported from an Access query).
Start Code
----------------------------------------------------------
Select Case frmTempType
Case 1 'Agent
intForm = Shell("C:\Progr am Files\Microsoft
Office\Office\W inword.exe " & "C:\TEMP\MailMe rge\NewAgent.do t", 1)
SendKeys "%f" 'Calls up File Menu
SendKeys "a" 'Calls up SAVE AS command
SendKeys NewFName 'Inserts filename into the filename field
SendKeys "{TAB}" 'Tabs to SAVE button
SendKeys "{TAB}"
SendKeys "~" 'Confirms and initiates the save.
Case 2 'Client
intForm = Shell("C:\Progr am Files\Microsoft
Office\Office\W inword.exe " & "C:\TEMP\MailMe rge\NewClient.d ot", 1)
SendKeys "%f" 'Calls up File Menu
SendKeys "a" 'Calls up SAVE AS command
SendKeys NewFName 'Inserts filename into the filename field
SendKeys "{TAB}" 'Tabs to SAVE button
SendKeys "{TAB}"
SendKeys "~" 'Confirms and initiates the save.
Case 3 'Sales
intForm = Shell("C:\Progr am Files\Microsoft
Office\Office\W inword.exe " & "C:\TEMP\MailMe rge\NewSales.do t", 1)
SendKeys "~" 'Confirms the import method of the text
file. Don't know why its not needed on the others.
SendKeys "%f" 'Calls up File Menu
SendKeys "a" 'Calls up SAVE AS command
SendKeys NewFName 'Inserts filename into the filename field
SendKeys "{TAB}" 'Tabs to SAVE button
SendKeys "{TAB}"
SendKeys "~" 'Confirms and initiates the save.
End Select
----------------------------------------------------------
End Code

The problem is that for some reason when the Sales Case (Case 3 above)
is initiated a text conversion box appears when it attempts to open the
file asking for what kind of conversion that I want to perform and for
some reason it doesn't perform the rest of the SendKey commands
correctly. Anyone have any insights on why the SendKey commands would
work fine in Case 1 & 2 but not in Case 3 above?

von

Nov 13 '05 #2
Please be more specific. What do you mean by "Automation "? Isn't the
use of SendKeys commands an 'automation' technique?

von

MacDermott wrote:
Automation is usually a much more flexible way to interact with Word.

<ba*********@sb cglobal.net> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
I have an issue where I have three Cases that SHOULD act the same but don't. If you look at the code below you will see that the general
premise is to open a MSWord template and then use SendKey commands to get it to save the file using a new name (NewFName is assigned earlier in the code).

A couple of issues to keep in mind. These are MailMerge templates that are attached to a Text Deliminted File (a separate one for each Case, i.e. Agent.txt, Client.txt and Sales.txt respectively). The text files were created in the same manner (exported from an Access query).
Start Code
----------------------------------------------------------
Select Case frmTempType
Case 1 'Agent
intForm = Shell("C:\Progr am Files\Microsoft
Office\Office\W inword.exe " & "C:\TEMP\MailMe rge\NewAgent.do t", 1)
SendKeys "%f" 'Calls up File Menu
SendKeys "a" 'Calls up SAVE AS command
SendKeys NewFName 'Inserts filename into the filename field
SendKeys "{TAB}" 'Tabs to SAVE button
SendKeys "{TAB}"
SendKeys "~" 'Confirms and initiates the save.
Case 2 'Client
intForm = Shell("C:\Progr am Files\Microsoft
Office\Office\W inword.exe " & "C:\TEMP\MailMe rge\NewClient.d ot", 1)
SendKeys "%f" 'Calls up File Menu
SendKeys "a" 'Calls up SAVE AS command
SendKeys NewFName 'Inserts filename into the filename field
SendKeys "{TAB}" 'Tabs to SAVE button
SendKeys "{TAB}"
SendKeys "~" 'Confirms and initiates the save.
Case 3 'Sales
intForm = Shell("C:\Progr am Files\Microsoft
Office\Office\W inword.exe " & "C:\TEMP\MailMe rge\NewSales.do t", 1)
SendKeys "~" 'Confirms the import method of the text
file. Don't know why its not needed on the others.
SendKeys "%f" 'Calls up File Menu
SendKeys "a" 'Calls up SAVE AS command
SendKeys NewFName 'Inserts filename into the filename field
SendKeys "{TAB}" 'Tabs to SAVE button
SendKeys "{TAB}"
SendKeys "~" 'Confirms and initiates the save.
End Select
----------------------------------------------------------
End Code

The problem is that for some reason when the Sales Case (Case 3 above) is initiated a text conversion box appears when it attempts to open the file asking for what kind of conversion that I want to perform and for some reason it doesn't perform the rest of the SendKey commands
correctly. Anyone have any insights on why the SendKey commands would work fine in Case 1 & 2 but not in Case 3 above?

von


Nov 13 '05 #3
"Automation " is Microsoft's term for the technique by which you can open an
instance of another (usually Office) program and interact with it
programmaticall y.

For example, once you've opened an instance of Word, instead of sending keys
to display the File, Open menu, and entering a file name, you could execute
code something like this: (AIR CODE)
objWord.Documen ts.Open MyFileName

It's a technique which should be covered in any intermediate to advanced VBA
coding text.

HTH

<ba*********@sb cglobal.net> wrote in message
news:11******** **************@ c13g2000cwb.goo glegroups.com.. .
Please be more specific. What do you mean by "Automation "? Isn't the
use of SendKeys commands an 'automation' technique?

von

MacDermott wrote:
Automation is usually a much more flexible way to interact with Word.

<ba*********@sb cglobal.net> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
I have an issue where I have three Cases that SHOULD act the same but don't. If you look at the code below you will see that the general
premise is to open a MSWord template and then use SendKey commands to get it to save the file using a new name (NewFName is assigned earlier in the code).

A couple of issues to keep in mind. These are MailMerge templates that are attached to a Text Deliminted File (a separate one for each Case, i.e. Agent.txt, Client.txt and Sales.txt respectively). The text files were created in the same manner (exported from an Access query).
Start Code
----------------------------------------------------------
Select Case frmTempType
Case 1 'Agent
intForm = Shell("C:\Progr am Files\Microsoft
Office\Office\W inword.exe " & "C:\TEMP\MailMe rge\NewAgent.do t", 1)
SendKeys "%f" 'Calls up File Menu
SendKeys "a" 'Calls up SAVE AS command
SendKeys NewFName 'Inserts filename into the filename field
SendKeys "{TAB}" 'Tabs to SAVE button
SendKeys "{TAB}"
SendKeys "~" 'Confirms and initiates the save.
Case 2 'Client
intForm = Shell("C:\Progr am Files\Microsoft
Office\Office\W inword.exe " & "C:\TEMP\MailMe rge\NewClient.d ot", 1)
SendKeys "%f" 'Calls up File Menu
SendKeys "a" 'Calls up SAVE AS command
SendKeys NewFName 'Inserts filename into the filename field
SendKeys "{TAB}" 'Tabs to SAVE button
SendKeys "{TAB}"
SendKeys "~" 'Confirms and initiates the save.
Case 3 'Sales
intForm = Shell("C:\Progr am Files\Microsoft
Office\Office\W inword.exe " & "C:\TEMP\MailMe rge\NewSales.do t", 1)
SendKeys "~" 'Confirms the import method of the text
file. Don't know why its not needed on the others.
SendKeys "%f" 'Calls up File Menu
SendKeys "a" 'Calls up SAVE AS command
SendKeys NewFName 'Inserts filename into the filename field
SendKeys "{TAB}" 'Tabs to SAVE button
SendKeys "{TAB}"
SendKeys "~" 'Confirms and initiates the save.
End Select
----------------------------------------------------------
End Code

The problem is that for some reason when the Sales Case (Case 3 above) is initiated a text conversion box appears when it attempts to open the file asking for what kind of conversion that I want to perform and for some reason it doesn't perform the rest of the SendKey commands
correctly. Anyone have any insights on why the SendKey commands would work fine in Case 1 & 2 but not in Case 3 above?

von

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3004
by: timdoyle05 | last post by:
Hi, I have a question relating to how Unix commands can be issued from Python programs. Im am currently writing a large test script in python and I need this script to call three other separate Python scripts, where each one executes in it own thread of control. I would like to use a Unix command to get each script to run in its own shell. I have tried using the "Commands" module but after I issue the first "command", execution blocks...
2
2483
by: Raquel | last post by:
Why can we not give db2 System commands (commands starting with 'db2' like db2ilist, db2look, db2move etc.) through the Command Center? It is so convenient to retrieve and change commands in the Command center but this facility does not seem to exist for System commands. Seems command Window and CLP are the only places where we can interactively issue these commands..darn it!!! Regards, Raquel.
0
1600
by: angelsoft | last post by:
How to send Microsoft Natural Keyboard keys with sendkey method ej. Windows Logo: Start menú, Windows Logo+R: Run dialog box
0
1853
by: Gunawan | last post by:
Can someone help me how to write console application to sendkey c:>sendkey {ALT}+{TAB} simulate key ALT+TAB TIA Gun
0
3895
by: Ralstoj | last post by:
Hi I am programing in Autocad with VB Autodesk have not given users access to new note function in Autocad CIVIL3d API. I am trying to work round this by creating notes using the sendkey command in Vb. I can get the add note dialog box to come up ok but it does not have focus as I believe it is a modeless dialog box as it gets focus when you move the mouse cursor over it. What I am after is a VB eample on how to send key strokes to the...
7
7685
by: JV | last post by:
I am running a large Access 2000 application (installed using Access Runtime) that uses many VB SendKeys, primarily to expand combo boxes On Enter. When trying to run it on Vista I get a "Permission denied" (error 70) error whenever entering a combo box. I have already changed the shortcut that starts access and opens the database to "Run as Administrator". I also changes msaccess.exe itself to "Run as Administrator". I also tried using...
6
4058
by: Peted | last post by:
Hi wondering what is the best way to do this Need a user to click a button, that sends 3 or 4 string based commands via a TCP/ip socket link I can connect to the ip device no problems, am using indy sockets, and can send information ok
12
19604
by: DAHMB | last post by:
I have a form that calls up a report in the form I have several date fields that have date input masks. I have created a cancel button as: Private Sub btnCancel_Click() On Error GoTo Err_btnCancel_Click Dim stDocName As String DoCmd.Close Exit_btnCancel_Click:
1
3146
by: John Dio | last post by:
I am trying to create a on screen key board. I simply want to send a key (Simulate the keyboard) to a combo box using the Handle of the control. The below code is not working
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9538
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10470
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10247
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10214
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6803
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5583
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2935
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.