-
Thanks for the above Matt. I did try to make it work but with no sucess. In the end to stop wasting more time I just made 100 statements one for each button. I may have another try later as I can't see why it wouldn't work.
I've basically finished everything now just updateing the Word help file after fixing my last error catcher tonight.
However (isn't there always) I decided to put another button on my toolbar to open the spreadsheet for easier editing, but I just can't make it work. The code I have for the Help Word doc functions correctly but using this as a basis, the code for the Excel doc just keeps jumping to the error statement. Could you advise where I'm going wrong. The two codes are below.
[VBA]
Sub Help() 'this opens the "Help" word.doc in the Mailfile folder (path below)
Dim wd As Object
Dim HelpPath As String
Dim AppOpen As Boolean
Dim ErrorMessage As Long
HelpPath = "C:\MailFile\MailFileHelp.doc"
On Error GoTo Message
Set wd = GetObject(, "word.application") 'Checks to see if the file is already open
wd.Documents.Open HelpPath 'and opens the file
wd.Visible = True
wd.Application.Activate 'Makes the application have the focus
GoTo NoMessage
Message:
ErrorMessage = MsgBox(" The help file could not be opened." & vbCr & vbCr & _
"Check that the file MailFileHelp.doc is in the folder " & vbCr & vbCr & _
" C:\MailFile\", vbOKOnly + vbExclamation, "Help file not found")
NoMessage:
Set wd = Nothing
End Sub
Sub Excel() 'this opens the MailFile.xls settings file in the Mailfile folder (path below)
Dim myXL As Object
Dim SettingPath As String
Dim AppOpen As Boolean
Dim ErrorMessage As Long
SettingPath = "C:\MailFile\MailFile.xls"
On Error GoTo Message
Set myXL = GetObject("C:\MailFile\MailFile.xls") 'Checks to see if the file is already open
'Set myXL = GetObject(, "Excel.application") 'Checks to see if the file is already open
myXL.Workbooks.Open SettingPath 'and opens the file
myXL.Visible = True
myXL.Application.Activate 'Makes the application have the focus
GoTo NoMessage
Message:
ErrorMessage = MsgBox(" The settings file could not be opened." & vbCr & vbCr & _
" Check that the file MailFile.xls is in the folder " & vbCr & vbCr & _
" C:\MailFile\", vbOKOnly + vbExclamation, "Excel file not found")
NoMessage:
Set myXL = Nothing
End Sub
[/VBA]
(I hate asking this as it must be something very basic but I've tried lots of things and nothing seems to work)
I'll post the completed programme as soon as I've done the help
Thanks
Jeff
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules