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