首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >我在outlook中创建了一个宏来将电子邮件数据导出到excel,但是在其中一个单元格的末尾添加了“<https”。我怎样才能解决这个问题?

我在outlook中创建了一个宏来将电子邮件数据导出到excel,但是在其中一个单元格的末尾添加了“<https”。我怎样才能解决这个问题?
EN

Stack Overflow用户
提问于 2018-12-13 01:07:58
回答 1查看 0关注 0票数 0

所以我的主要问题是:运行宏并检查excel后,“附加信息”列后面有“<https”。我似乎无法弄清楚为什么会这样做,所以如果有人可以看看代码,看看他们是否看到了我可能会遗漏的问题。如果它不是代码的问题,那么我认为它必须是电子邮件格式的问题。提前致谢!

这是我宏的代码的副本。

Option Explicit

Sub CopyToExcel()
Dim xlApp As Object
Dim xlWB As Object
Dim xlSheet As Object
Dim olItem As Outlook.MailItem
Dim vText As Variant
Dim sText As String
Dim vItem As Variant
Dim i As Long
Dim rCount As Long
Dim bXStarted As Boolean
Const strPath As String = "P:\Yard Check\AkronYardCheck.xlsx" 'the path of 
the workbook

If Application.ActiveExplorer.Selection.Count = 0 Then
MsgBox "No Items selected!", vbCritical, "Error"
Exit Sub
End If
On Error Resume Next
Set xlApp = GetObject(, "Excel.Application")
If Err <> 0 Then
Application.StatusBar = "Please wait while Excel source is opened ... "
Set xlApp = CreateObject("Excel.Application")
bXStarted = True
End If
On Error GoTo 0
'Open the workbook to input the data
Set xlWB = xlApp.Workbooks.Open(strPath)
Set xlSheet = xlWB.Sheets("Sheet1")

'Process each selected record
rCount = xlSheet.UsedRange.Rows.Count
For Each olItem In Application.ActiveExplorer.Selection
sText = olItem.Body
vText = Split(sText, Chr(13))
'Find the next empty line of the worksheet
 rCount = rCount + 1
'Check each line of text in the message body
For i = UBound(vText) To 0 Step -1
  If InStr(1, vText(i), "Trailer Number:") > 0 Then
        vItem = Split(vText(i), Chr(58))
        xlSheet.Range("A" & rCount) = Trim(vItem(1))
    End If

    If InStr(1, vText(i), "Loaded/Empty:") > 0 Then
        vItem = Split(vText(i), Chr(58))
        xlSheet.Range("B" & rCount) = Trim(vItem(1))
    End If

    If InStr(1, vText(i), "Notes:") > 0 Then
        vItem = Split(vText(i), Chr(58))
        xlSheet.Range("C" & rCount) = Trim(vItem(1))
    End If

    If InStr(1, vText(i), "Additional Info:") > 0 Then
        vItem = Split(vText(i), Chr(58))
        xlSheet.Range("D" & rCount) = Trim(vItem(1))
    End If
Next i
xlWB.Save
Next olItem
xlWB.Close SaveChanges:=True
If bXStarted Then
xlApp.Quit
End If
Set xlApp = Nothing
Set xlWB = Nothing
Set xlSheet = Nothing
Set olItem = Nothing
End Sub

Trailer Number: 123

Loaded/Empty: Empty

Notes: Damage - Landing Gear | Locked Out | No Securement

Additional Info: Example

Screenshot of my excel file:

在此处输入图像描述
在此处输入图像描述
EN

回答 1

Stack Overflow用户

发布于 2018-12-13 10:16:23

我所要做的只是在文本框输入后添加分页符。(我收到的是来自网络表单的电子邮件)2333

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100003063

复制
相关文章

相似问题

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