首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >VBA Office 2010 Outlook问题

VBA Office 2010 Outlook问题
EN

Stack Overflow用户
提问于 2012-05-24 22:12:12
回答 1查看 2.1K关注 0票数 3

我刚刚从我们的IT人员那里升级到了office 2010,这样我就可以检查我在Office中编写的VBA脚本的功能。到目前为止,我遇到的唯一一个是在Outlook 2010中,如下所示。我已经在每一行的末尾标上了3个*号,它们不工作。有人能给我建议吗?我在网上找不到任何解决方案(地址中的....号仅用于删除此处的文件路径)

代码语言:javascript
复制
Sub UpdatedQMISReply()

Location = InputBox("Please enter the UNC (http://) path for the new file", "UNC location")
Location2 = InputBox("Please enter the QMIS path for the new file", "UNC location")

'
' UpdatedQMISReply Macro
' Insert QMIS Document Updated text
'
    ActiveInspector.WordEditor.Application.Selection.TypeText Text:="Dear User,"
    ActiveInspector.WordEditor.Application.Selection.TypeParagraph
    ActiveInspector.WordEditor.Application.Selection.TypeParagraph
    ActiveInspector.WordEditor.Application.Selection.TypeText Text:="This email is to confirm that your recent file update request to QMIS has now been completed. I have uploaded all the requested files and have saved a copy into the archive folder "
ActiveInspector.WordEditor.Application.Selection.TypeText Text:="(if an old file existed)."
ActiveInspector.WordEditor.Application.Selection.TypeParagraph
ActiveInspector.WordEditor.Application.Selection.TypeParagraph
ActiveInspector.WordEditor.Application.Selection.TypeText Text:="The location on QMIS for the uploaded document is: "


***ActiveInspector.WordEditor.Application.Selection.Hyperlinks.Add Anchor:=Selection.Range, Address:=Location, SubAddress:="", ScreenTip:="", TextToDisplay:=Location2***


ActiveInspector.WordEditor.Application.Selection.TypeParagraph
ActiveInspector.WordEditor.Application.Selection.TypeParagraph
ActiveInspector.WordEditor.Application.Selection.TypeText Text:="If your update was concerning a Health & Safety Document such as a Risk Assessment, or Safe System of Work, then please note that the naming convention for these documents is changing, also the location of the document may change without prior warning as the QMIS infrastructure is modified."
ActiveInspector.WordEditor.Application.Selection.TypeParagraph
ActiveInspector.WordEditor.Application.Selection.TypeParagraph
ActiveInspector.WordEditor.Application.Selection.TypeText Text:="Should you have any further queries regarding this update then please do not hesitate to contact me"
ActiveInspector.WordEditor.Application.Selection.TypeParagraph
ActiveInspector.WordEditor.Application.Selection.TypeParagraph
ActiveInspector.WordEditor.Application.Selection.TypeText Text:="Regards"
End Sub
Sub DocumentRenewalNeeded()
'
' QMIS.DocumentRenewalNeeded Macro
' Macro created 26/10/2011 by stefan.wright
Dim myOlApp As Outlook.Application
Dim myItem As Outlook.MailItem
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
myItem.Subject = "QMIS Document Review Needed"


***myItem.Attachments.Add "\\.........\sites\..........\.........\DOCUMENT UPDATE TRACKER\.............xls"***


myItem.Display

Selection.TypeText Text:="Dear User,"
Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeText Text:="This email is to inform you that you have documents that are currently out of date on QMIS Document Library. These documents could either be on the Quality worksheet or the HS worksheet so please ensure you check both. Please could you view the QMIS Document Updater Spreadsheet to view the documents which you are responsible for, This can be done by clicking the small arrow in the box which says 'Responsible Person' and then selecting your name, if you then do the same in the 'Colour Code' box and select '2' or '3' you will find the documents which should have been reviewed. If you should find that you are listed on a document and this is incorrect then please let me know and if possible advise me of who should be responsible for that document."
Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeText Text:="The spreadsheet of QMIS updates is attached to this email."
Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeText Text:="Should you have any further queries regarding this update then please do not hesitate to contact me.    This email will be sent out monthly to those people who have outstanding updates to be completed."
Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeText Text:="Regards"
End Sub
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-05-24 22:58:42

未经测试的

尝尝这个

代码语言:javascript
复制
Sub UpdatedQMISReply()
    Dim msg1 As String, msg2 As String
    Dim doc As Object, sel As Object
    Dim Location, Location2

    msg1 = "Please enter the UNC (http://) path for the new file"
    msg2 = "Please enter the QMIS path for the new file"

    Location = InputBox(msg1, "UNC location")
    Location2 = InputBox(msg2, "UNC location")

    Set doc = ActiveInspector.WordEditor
    Set sel = doc.Application.Selection

    With sel
        .TypeText Text:="Dear User,"
        .TypeParagraph
        .TypeParagraph
        .TypeText Text:="This email is to confirm that your recent " & _
                        "file update request to QMIS has now been " & _
                        "completed. I have uploaded all the requested " & _
                        "files and have saved a copy into the archive folder "
        .TypeText Text:="(if an old file existed)."
        .TypeParagraph
        .TypeParagraph
        .TypeText Text:="The location on QMIS for the uploaded document is: "

        .Hyperlinks.Add Anchor:=.Range, Address:=Location, SubAddress:="", ScreenTip:="", TextToDisplay:=Location2

        .TypeParagraph
        .TypeParagraph
        .TypeText Text:="If your update was concerning a Health & Safety " & _
                        "Document such as a Risk Assessment, or Safe System" & _
                        " of Work, then please note that the naming " & _
                        "convention for these documents is changing, also " & _
                        "the location of the document may change without " & _
                        "prior warning as the QMIS infrastructure is modified."
        .TypeParagraph
        .TypeParagraph
        .TypeText Text:="Should you have any further queries regarding " & _
                        "this update then please do not hesitate to contact me"
        .TypeParagraph
        .TypeParagraph
        .TypeText Text:="Regards"
    End With
End Sub

或者,在实际代码中,将

***ActiveInspector.WordEditor.Application.Selection.Hyperlinks.Add Anchor:=Selection.Range, Address:=Location, SubAddress:="", ScreenTip:="", TextToDisplay:=Location2***

使用

代码语言:javascript
复制
ActiveInspector.WordEditor.Application.Selection.Hyperlinks.Add _
Anchor:=ActiveInspector.WordEditor.Application.Selection.Range, _
Address:=Location, SubAddress:="", ScreenTip:="", TextToDisplay:=Location2
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10739206

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档