问题描述
我希望该系统对我的用户尽可能自动化.现在,我有在用户单击按钮时运行的代码.该代码获取数据,旨在通过邮件合并将其应用于Word文档.
I'd like the system to be as automated for my users as possible. Right now, I have code that runs when the user clicks a button. The code takes data with the intention of applying it to a word document via mail merge.
一切正常,但总会弹出一条消息,提示
Everything works as intended except there's always a message that pops up saying
选择* FROM'TAGS $'
Select * FROM 'TAGS$'
数据库中的数据将放置在文档中.你想要_____吗 继续吗?
Data from your database will be placed in the document. Do you want to continue?
我需要使此操作尽可能简单,不要冒险让用户选择否",因为他们很困惑.如果他们选择了是",VBA如何自动进行并接受数据放置?
I need to keep this as simple as possible without risking users selecting "No" because they're confused. How can VBA automatically proceed and accept the data placement, as it would had they selected "Yes"?
我尝试仅使用以下代码来阻止警报,希望它默认为是"并继续执行,但没有用.
I tried just using the following code to block alerts in hopes it would default "Yes" and proceed, but it didn't work.
Application.DisplayAlerts = False
这就是我所拥有的
Sub RunMailMerge()
Application.ScreenUpdating = False
Dim wdOutputName, wdInputName As String
wdOutputName = ThisWorkbook.Path & "\nametags - " _
& Format(Date, "d mmm yyyy")
wdInputName = ThisWorkbook.Path & "\nametags.docx"
' open the mail merge layout file
Dim wdDoc As Object
Set wdDoc = GetObject(wdInputName, "Word.document")
wdDoc.Application.Visible = True
With wdDoc.MailMerge
.MainDocumentType = wdFormLetters
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
.Execute Pause:=False
End With
'Application.ScreenUpdating = True
'show and save output file
wdDoc.Application.Visible = True
wdDoc.Application.ActiveDocument.SaveAs wdOutputName
' cleanup
wdDoc.Close SaveChanges:=False
'activedoc.Close
Set wdDoc = Nothing
End Sub
推荐答案
http://support.microsoft. com/kb/825765
HKEY_CURRENT_USER \ Software \ Microsoft \ Office \ 15.0 \ Word \ Options
HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Word\Options
"SQLSecurityCheck" = dword:00000000
"SQLSecurityCheck"=dword:00000000
Start Registry Editor.
Locate and then click the following registry key:
HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Word\Options
On the Edit menu, point to New, and then click DWORD Value.
Under Name, type:
SQLSecurityCheck
Double-click SQLSecurityCheck.
In the Value data box, type:
00000000
Click OK.
HKEY_CURRENT_USER \ Software \ Microsoft \ Office \ 14.0 \ Word \ Options
HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Word\Options
"SQLSecurityCheck" = dword:00000000
"SQLSecurityCheck"=dword:00000000
Start Registry Editor.
Locate and then click the following registry key:
HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Word\Options
On the Edit menu, point to New, and then click DWORD Value.
Under Name, type:
SQLSecurityCheck
Double-click SQLSecurityCheck.
In the Value data box, type:
00000000
Click OK.
HKEY_CURRENT_USER \ Software \ Microsoft \ Office \ 12.0 \ Word \ Options
HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Word\Options
"SQLSecurityCheck" = dword:00000000
"SQLSecurityCheck"=dword:00000000
Start Registry Editor.
Locate and then click the following registry key:
HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Word\Options
On the Edit menu, point to New, and then click DWORD Value.
Under Name, type:
SQLSecurityCheck
Double-click SQLSecurityCheck.
In the Value data box, type:
00000000
Click OK.
HKEY_CURRENT_USER \ Software \ Microsoft \ Office \ 11.0 \ Word \ Options
HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Word\Options
"SQLSecurityCheck" = dword:00000000
"SQLSecurityCheck"=dword:00000000
Start Registry Editor.
Locate and then click the following registry key:
HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Word\Options
Click Edit, point to New, and then click DWORD Value.
Under Name, type:
SQLSecurityCheck
Double-click SQLSecurityCheck.
In the Value data box, type:
00000000
Click OK.
HKEY_CURRENT_USER \ Software \ Microsoft \ Office \ 10.0 \ Word \ Options
HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Word\Options
"SQLSecurityCheck" = dword:00000000
"SQLSecurityCheck"=dword:00000000
为此,请按照下列步骤操作:
To do this, follow these steps:
Start Registry Editor.
Locate and then click the following registry key:
HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Word\Options
Click Edit, point to New, and then click DWORD Value.
Under Name, type:
SQLSecurityCheck
Double-click SQLSecurityCheck.
In the Value data box, type:
00000000
Click OK.
这篇关于excel VBA在邮件合并过程中出现提示时自动选择“是"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!