I
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Cleaning up shipping files (2002)
Home » Forums » AskWoody support » Productivity software by function » MS Outlook and email programs » Cleaning up shipping files (2002)
- This topic has 8 replies, 3 voices, and was last updated 22 years, 5 months ago.
Viewing 1 reply threadAuthorReplies-
WSAndrewO
AskWoody LoungerOctober 18, 2002 at 9:02 pm #625146 -
WSarage
AskWoody Lounger -
WSAndrewO
AskWoody Lounger -
WSarage
AskWoody Lounger
-
-
WSAndrewO
AskWoody LoungerOctober 25, 2002 at 8:54 pm #626807Arage
OK – try the following code.
Cut and paste this to the Outlook “ThisOutLookSession” code space.
Note that by default Outlook disables macros and doesn’t tell you it has – you’ll need to enable them to at most ‘Medium’ security.I’ve had to make some assumptions for the purposes of design that you will need to review.
This routine triggers on the NEWMAIL event, and looks for mail with file attachments
If it sees file types CSV TXT or 001 it then asks if it should convert them.
You can change the file types looked for by modifying the variable ‘MyExts’ – you can add more by just typing .EXT inside the quotes where EXT is your new extension.
For testing I also used directory C:TEMP to create reformatted files in – change MyPath as needed for your network drive.
I have coded changes to data as follows –
Column 2 has 001 added
Columns 4 & 5 have quotes
Column 4 has R00 at front
Column 5 has S045 at front
The LAST column has date extended. Note that I specifically coded it as the last, rather than 10th column because this protects the code if you text fields ever contain commas
The program is designed so that similar changes could be made without a big deal
Public Myolapp As Variant
Public I As Long
Public J As Long
Public MyExt As String
Public MyExts As String
Public MyFile As String
Public MyPath As StringPrivate Sub Application_NewMail()
‘ Identifies incoming mail that has an attachment that matches our target type
‘ if so, asks, and translates it to new format and save‘ Change the following two constants as required to get things working right
‘ First is simply a list of valid extensions to trigger reformating actionMyExts = “.CSV.TXT.001”
‘ Second is the path for re-formatted files to go to
MyPath = “C:TEMP”
‘ Preliminary setup to view new mail
Set Myolapp = CreateObject(“Outlook.Application”)
Set myNameSpace = Myolapp.GetNamespace(“MAPI”)
Set Myolapp.ActiveExplorer.CurrentFolder = _
myNameSpace.GetDefaultFolder(olFolderInbox)‘ Identify unread mail and deal with it
With Myolapp.ActiveExplorer.CurrentFolder
For I = 1 To .Items.Count
If .Items(I).UnRead = True Then
For J = 1 To .Items(I).Attachments.Count
MyFile = .Items(I).Attachments(J).DisplayName
MyExt = Right(MyFile, 4)
If InStr(1, MyExts, MyExt, vbTextCompare) > 0 Then
If MsgBox(“Reformat file ‘” & MyFile & “‘?”, buttons:=vbOKCancel) = 1 Then
MyFile = MyPath & “” & Left(MyFile, Len(MyFile) – 4) & “._B4”
.Items(I).Attachments(J).SaveAsFile MyFile
Reformat MyFile
End If
.Items(I).UnRead = False
End If
Next J
End If
Next I
End WithEnd Sub
Sub Reformat(target As String)
Dim I As Long
Dim J As Long
Dim DateCol As Long
Dim MyRec As String
Dim MyFields(100) As String‘ This would have been easier in Excel but it cannot refrain from re-formating quotes
‘ so – lets just do it the hard way
‘ Just read the file line by line, break it out into fields, and then rewriteOpen target For Input As #1
Open Left(target, Len(target) – 4) & “.CSV” For Output As #2
Line Input #1, MyRec
While Not EOF(1)
‘ it is easier and less bug-prone to split into fields than try to be clever
J = 1
I = InStr(1, MyRec, “,”)
While I > 0
MyFields(J) = Left(MyRec, I – 1)
MyRec = Mid(MyRec, I + 1)
J = J + 1
I = InStr(1, MyRec, “,”)
Wend
MyFields(J) = MyRec‘ This is the section that makes the requested changes
MyFields(2) = Left(MyFields(2), Len(MyFields(2)) – 1) & “001”””
MyFields(4) = “””R00” & MyFields(4) & “”””
MyFields(5) = “””S045” & MyFields(5) & “”””
‘ Set the column for date as the last column.
‘ Why? to protect from possible commas in the text fields
MyFields(J) = Left(MyFields(J), Len(MyFields(J)) – 3) & “20” & Right(MyFields(J), 3)‘ then we put it all back together and write it out
For I = 1 To J – 1
Print #2, MyFields(I); “,”;
Next I
Print #2, MyFields(J)
Line Input #1, MyRec
Wend
Close #1
Close #2End Sub
-
-
-
WSRknott
AskWoody Lounger -
WSarage
AskWoody Lounger -
WSAndrewO
AskWoody LoungerOctober 25, 2002 at 9:54 pm #626808Oops
Reading between the lines of this message I detect that the changes requested are not as ‘mindless’ as I coded.
I begin to think that things like “S045” only have to be added if they are not already there.
My suggestion is that we send direct emails for the fine-tuning – rather than bother the board.
-
-
Viewing 1 reply thread -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Oracle kinda-sorta tells customers it was pwned
by
Nibbled To Death By Ducks
5 hours, 42 minutes ago -
Global data centers (AI) are driving a big increase in electricity demand
by
Kathy Stevens
16 hours, 2 minutes ago -
Office apps read-only for family members
by
b
18 hours, 38 minutes ago -
Defunct domain for Microsoft account
by
CWBillow
15 hours, 30 minutes ago -
24H2??
by
CWBillow
5 hours, 41 minutes ago -
W11 23H2 April Updates threw ‘class not registered’
by
WindowsPersister
1 day, 3 hours ago -
Master patch listing for April 8th, 2025
by
Susan Bradley
9 minutes ago -
TotalAV safety warning popup
by
Theodore Nicholson
15 hours, 26 minutes ago -
two pages side by side land scape
by
marc
2 days, 16 hours ago -
Deleting obsolete OneNote notebooks
by
afillat
2 days, 18 hours ago -
Word/Outlook 2024 vs Dragon Professional 16
by
Kathy Stevens
1 day, 21 hours ago -
Security Essentials or Defender?
by
MalcolmP
2 days ago -
April 2025 updates out
by
Susan Bradley
20 minutes ago -
Framework to stop selling some PCs in the US due to new tariffs
by
Alex5723
1 day, 17 hours ago -
WARNING about Nvidia driver version 572.83 and 4000/5000 series cards
by
Bob99
1 day, 7 hours ago -
Creating an Index in Word 365
by
CWBillow
2 days, 10 hours ago -
Coming at Word 365 and Table of Contents
by
CWBillow
22 hours, 10 minutes ago -
Windows 11 Insider Preview Build 22635.5170 (23H2) released to BETA
by
joep517
3 days, 13 hours ago -
Has the Microsoft Account Sharing Problem Been Fixed?
by
jknauth
3 days, 16 hours ago -
W11 24H2 – Susan Bradley
by
G Pickerell
3 days, 18 hours ago -
7 tips to get the most out of Windows 11
by
Alex5723
3 days, 16 hours ago -
Using Office apps with non-Microsoft cloud services
by
Peter Deegan
3 days, 10 hours ago -
I installed Windows 11 24H2
by
Will Fastie
1 day, 16 hours ago -
NotifyIcons — Put that System tray to work!
by
Deanna McElveen
3 days, 22 hours ago -
Decisions to be made before moving to Windows 11
by
Susan Bradley
15 hours, 35 minutes ago -
Port of Seattle says ransomware breach impacts 90,000 people
by
Nibbled To Death By Ducks
4 days, 6 hours ago -
Looking for personal finance software with budgeting capabilities
by
cellsee6
3 days, 14 hours ago -
ATT/Yahoo Secure Mail Key
by
Lil88reb
3 days, 14 hours ago -
Devices with apps using sprotect.sys driver might stop responding
by
Alex5723
4 days, 23 hours ago -
Neowin – 20 times computers embarrassed themselves with public BSODs and goofups
by
EP
5 days, 8 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.