Convert old wordbasic code into VBA that will run now

Joined
Nov 8, 2023
Messages
1
Reaction score
0
Hi,

I have an old wordbasic macro which i created years ago which now won't run, but I don't now know how to start to change it.

The macros basically is for a file which contains mailmerged data. 1 of the fields is a filename which is of a photo of the person... So it's creating a photo contact sheet.

In the current document, it makes sure you start at the top... Searches for ** which signifies the start of the file name. It then selects the filename, and if the file exists, it inserts the picture.

Can anyone help?? (There is a bit of code in here to do with bullet points, but thats not needed now)

Sub PhotoAdd()
'
' PhotoAdd Macro
'
'
Selection.HomeKey Unit:=wdStory

START:
EditFind .Find = "**", .Direction = 0, .MatchCase = 0, .WholeWord = 1, .PatternMatch = 1, .SoundsLike = 0, .Format = 0, .Wrap = 0
While EditFindFound()
INSTYPE$ = Selection$()
EditClear
EndOfLine 1
CharLeft 1, 1
INSFILE$ = Selection$()
If Files$(INSFILE$) <> "" Then
InsertPicture .Name = INSFILE$, .LinkToFile = "0"
GoTo START
End If
Else
MsgBox ("HERE")
Err = 1078
GoTo notfound
End If
Wend
MsgBox("All Bullets Points and Signatures Added", "Add Bullets Points and Signatures", 64)
GoTo bye
notfound:
If Err = 1078 Or Err = 1177 Then
If INSTYPE$ = "+BUL+" Then
ERRMSG$ = "Unable to add Bullet Point " + INSFILE$
MsgBox(ERRMSG$, "Add Bullet Points", 48)
Err = 0
GoTo START
Else
ERRMSG$ = "Unable to add Signature " + INSFILE$
MsgBox(ERRMSG$, "Add Signatures", 48)
Err = 0
GoTo START
End If
End If
bye:
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top