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, 6 months ago.
Viewing 1 reply threadAuthorReplies-
WSAndrewO
AskWoody LoungerOctober 18, 2002 at 9:02 pm #625146 -
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
-
HP Pavilion Will Not Wake Up After Being Idle for Longer Period
by
WSwalterwood44
4 hours, 16 minutes ago -
Make a Windows 11 Local Account Passwordless
by
Drcard:))
3 hours, 50 minutes ago -
Ubuntu 25.04 (Plucky Puffin)
by
Alex5723
7 hours, 25 minutes ago -
24H2 fixed??
by
CWBillow
10 hours, 7 minutes ago -
Uninstalr Updates
by
jv16
12 hours, 34 minutes ago -
Apple zero days for April
by
Susan Bradley
17 hours, 59 minutes ago -
CVE program gets last-minute funding from CISA – and maybe a new home
by
Nibbled To Death By Ducks
23 hours, 29 minutes ago -
Whistleblower describes DOGE IT dept rumpus at America’s labor watchdog
by
Nibbled To Death By Ducks
1 day, 11 hours ago -
Seeing BSOD’s on 24H2?
by
Susan Bradley
18 hours, 13 minutes ago -
TUT For Private Llama LLM, Local Installation and Isolated from the Internet.
by
bbearren
1 day, 1 hour ago -
Upgrade from Windows 10 to 11
by
Holdsworth8
1 day, 19 hours ago -
Microsoft : AI-powered deception: Emerging fraud threats and countermeasures
by
Alex5723
1 day, 22 hours ago -
0patch
by
WSjcgc50
23 hours, 47 minutes ago -
Devices might encounter blue screen exception with the recent Windows updates
by
Susan Bradley
1 day, 16 hours ago -
Windows 11 Insider Preview Build 22631.5261 (23H2) released to Release Preview
by
joep517
2 days, 1 hour ago -
Problem opening image attachments
by
RobertG
2 days, 3 hours ago -
advice for setting up a new windows computer
by
routtco1001
2 days, 18 hours ago -
It’s Identity Theft Day!
by
Susan Bradley
1 day, 22 hours ago -
Android 15 require minimum 32GB of storage
by
Alex5723
2 days, 22 hours ago -
Mac Mini 2018, iPhone 6s 2015 Are Now Vintage
by
Alex5723
2 days, 23 hours ago -
Hertz says hackers stole customer credit card and driver’s license data
by
Alex5723
2 days, 23 hours ago -
Firefox became sluggish
by
Rick Corbett
15 hours, 55 minutes ago -
Windows 10 Build 19045.5794 (22H2) to Release Preview Channel
by
joep517
3 days, 3 hours ago -
Windows 11 Insider Preview Build 22635.5235 (23H2) released to BETA
by
joep517
3 days, 4 hours ago -
A Funny Thing Happened on the Way to the Forum
by
bbearren
2 days, 1 hour ago -
Download speeds only 0.3Mbps after 24H2 upgrade on WiFi and Ethernet
by
John
6 hours, 21 minutes ago -
T-Mobile 5G Wireless Internet
by
WSmmi16
2 days, 1 hour ago -
Clock missing above calendar in Windows 10
by
WSCape Sand
3 hours, 21 minutes ago -
Formula to Calculate Q1, Q2, Q3, or Q4 of the Year?
by
WSJon5
3 days, 18 hours ago -
The time has come for AI-generated art
by
Catherine Barrett
2 days, 22 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.