View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dan the Man[_2_] Dan the Man[_2_] is offline
external usenet poster
 
Posts: 145
Default Help with my coding problem?

I'm hoping that someone can help me figure out a coding problem that I
SCREWED UP. I had this code in my Microsoft Word VB Editor that you see
below. The code worked PERFECTLY until I stupidly tried to edit it without
first making a backup. I know, first rule of any work is to make a backup, so
I can't believe I forgot to do that.

As an FYI, the "code" contained below was interfacing with one of my Excel
Workbooks, and allowed me to chose a client name from a dropdown menu (in
Excel), and when the name was chosen, Excel would call up a "Word", and the
Userform that was created would also open. This would then allow me to input
narrative comments into the Userform.

As a result of my "editing", I can select a client name (on the Excel
Workbook), but "Word" and "The Userform" no longer opens (actually it looks
as if it is trying to open, but cannot).

If some kind and knowledge person could look at the code below and let me
know if you see anything that I am leaving out I'd greatly appreciate it.
I've also emailed a few friends for suggestions, but wanted to post here as
well in order to attempt a "resolve" as soon as possible. I so depend upon
computer programs to do their job, so when they don't (thanks to my errors) I
am quite frustrated.

Dan

The Code in the MS Word "Sample Note.doc" VB Editor Module is as follows:

Sub UpdateComments(parm1)

On Error Resume Next

Documents.Open FileName:=parm1

If Not FileExists(parm1) Then ' Check if file/folder exists .....
MsgBox "File " & parm1 & " does not exist", vbOKCancel
Exit Sub
End If

UserForm1.Show vbModeless

End Sub
__________________________________________________ ___________________
Function FileExists(fname) As Boolean
' Returns TRUE if the file exists
Dim x As String
x = Dir(fname)
If x < "" Then FileExists = True _
Else FileExists = False
End Function