D
Dan the Man
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.
Dan
The Code in the MS Word Sample.doc VB Editor Module
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
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.
Dan
The Code in the MS Word Sample.doc VB Editor Module
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