Could this code be better written?

R

Rita King

I have the following code which works quite well. I am just wondering
whether there is a more effective way of writing this code.

I have a form with command buttons (about a dozen of them) to open to a
specific directory so the user can retrieve a file. The macro collects the
current document path, opens the file from the directory selected by the
user, and sets the document path back to what it was before running the
macro.

' This is part of the script from the form called frmFileOpen :
Private Sub cmdArtClerk_Click()
Dim strOldDir As String
strOldDir = Options.DefaultFilePath(wdDocumentsPath)
ChangeFileOpenDirectory "Y:\Masters\ArtClerk"
Call StandardMacs.DoIt
ChangeFileOpenDirectory strOldDir
End Sub

' This is the script from a Module called StandardMacs:
Sub DoIt() 'user picks a file to open from the dialog
'the file is opened and the dialog hidden and removed from
memory
Dialogs(wdDialogFileOpen).Show
frmFileOpen.Hide
Unload frmFileOpen
End Sub

Thanks
 

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