Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-01-2021, 09:30 PM
gmayor's Avatar
gmayor gmayor is offline Barcode Font Macro Windows 10 Barcode Font Macro Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default


Assuming the body of the appointment item is as you have described then you can use the Outlook Word Editor to either replace the number with a barcode or append a barcode. As written the macro below will replace the number with a QR barcode and leave the item open. If you close without saving the original item will remain. If you remove the quote from the start of the two lines near the end, the text with barcodes will be copied to the clipboard and the item closed without saving.
Code:
Sub AddBarCode()
'Graham Mayor - https://www.gmayor.com - Last updated - 02 Apr 2021
Dim olItem As AppointmentItem
Dim olInsp As Outlook.Inspector
Dim wdDoc As Object
Dim oRng As Object
Dim oPara As Object
Dim i As Integer
Dim sNum As String
    On Error Resume Next
    Select Case Outlook.Application.ActiveWindow.Class
        Case olInspector
            Set olItem = ActiveInspector.currentItem
        Case olExplorer
            Set olItem = Application.ActiveExplorer.Selection.Item(1)
    End Select
    With olItem
        .Save
        Set olInsp = .GetInspector
        Set wdDoc = olInsp.WordEditor
        Set oRng = wdDoc.Range
        oRng.Text = Replace(oRng.Text, Chr(11), Chr(13))
        For i = 1 To oRng.Paragraphs.Count
            Set oPara = oRng.Paragraphs(i).Range
            oPara.End = oPara.End - 1
            If InStr(1, oPara.Text, ":") > 0 Then
                oPara.moveStartuntil ":"
                oPara.Start = oPara.Start + 2
                sNum = oPara.Text
                'optional next line puts the code after the number
                'oPara.collapse 0
                oRng.Fields.Add oPara, 99, Chr(34) & sNum & Chr(34) & Chr(32) & "QR" & " \t", False
            End If
        Next i
        .Display
        'oRng.Copy
        'olItem.Close olDiscard
    End With
lbl_Exit:
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #2  
Old 04-03-2021, 05:18 AM
komobu komobu is offline Barcode Font Macro Windows XP Barcode Font Macro Office 2003
Advanced Beginner
Barcode Font Macro
 
Join Date: Feb 2011
Posts: 34
komobu is on a distinguished road
Default

Thanks for your help.

Initially I was getting an syntax error, but I was trying to add your code to one of my other modules. I added a new module, and pasted your code and no errors are returned.

When I run the macro however, nothing happens. No screen flash or anything visible at all.

I checked the clipboard and there was noting in it.

I removed the quote from the two lines near the end (oRng.Copy) and (olItem.Close olDiscard) Re ran the macro and again nothing. Also checked the clipboard by using "Control V" and nothing is there.

Here is a copy of what my calendar item looks like with data in it:

VIN: 1GMZU62hX3ZA92085
Od: 200236
Plate: XYG7365

State Inspection
Sticker Number: X0337728
Insert Number: 22944514


Not sure if it matters, I am using Outlook 2010. I dont know that I have anything installed in outlook for QR Codes.

I am using Code 39 which is a Barcode font that I installed. If I add an asterisk to the beginning of the alphanumeric and to the end, my barcode reader will read it. Without those asterisks, the code reader will not read it.
So the Plate for example would be *XYG7365*

One thing I realized was as soon as I add an asterisk to the front and rear, the font gets changed to bold. I have to find out how to turn that setting off.

I am also wondering if it may be easier to convert my calendar item to the following:


VIN:
*1GMZU62hX3ZA92085*

Od:
*200236*

Plate:
*XYG7365*

State Inspection

Sticker Number:
*X0337728*

Insert Number:
*22944514*



This way I could actually just highlight the lines myself and change the font. But I really would like to get a macro to do it.


Thanks again for your help
Reply With Quote
  #3  
Old 04-28-2021, 01:06 PM
komobu komobu is offline Barcode Font Macro Windows XP Barcode Font Macro Office 2010
Advanced Beginner
Barcode Font Macro
 
Join Date: Feb 2011
Posts: 34
komobu is on a distinguished road
Default

Graham;

I removed Outlook 2010 and am only using outlook 365 on my pc now with windows 10 professional.

I tried this code again and I cant believe how well this code works for my needs. It performs beyond my expectations.

Is there a way I could add items to it?

Like say I need to add a name between the 3rd and 4th line?

or If I need to add a couple of chr(34)s after the qr code for line 2 and before line 3?

I am the only one who uses this computer so I could add the stuff myself into the vba code but am not sure how, since this is using a for next loop.

Background
My company form has 5 items
VIN: (Vehicle Identification Number)
OD: (Milage)
Plate: (License)
Sticker Number: (Certificate Number)
Insert Number: (Certificate Number)

All this data gets entered into a state webpage. Their web page has 11 items. it is so much easier and faster to use a barcode reader to enter the data into the webpage, rather than me type it in or using the mouse

But their web page isnt in the order of our form, and I might need to press the tab key three times after one of there items to get to the field for my next item.

Thanks for any help you could provide. I really am thankful.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Barcode Font Macro Barcode Scanning Sueade Excel 1 11-11-2015 04:07 PM
Barcode Font Macro Looping Macro to Change Font, Font Size, and Give Heading 1 WH7262 Word VBA 1 08-26-2014 03:46 PM
MICROSOFT barcode control -changing the barcode image in realtime artner0112 Excel 1 12-18-2011 09:33 AM
Barcode Font Macro Postnet Barcode Doc_man Mail Merge 1 09-29-2010 03:06 AM
barcode add ins ???? quince Office 2 11-11-2005 12:40 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:35 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft