Problems with ChDrive, ChDir

S

Sophie

Hello Everyone!

I've got two practically identical macros. One works all
the time, one never. I can't work out why Open works, but
SaveAs doesn't. Does anyone have any idea??

TIA

Sxx


Sub FileOpenDirectory()
Dim strDirectory As String

strDirectory = Excel.CommandBars.ActionControl.Tag

ChDrive Left(strDirectory, 1)
ChDir strDirectory
Application.Dialogs(xlDialogOpen).Show

End Sub
Sub FileSaveAsDirectory()
Dim strDirectory As String

strDirectory = Excel.CommandBars.ActionControl.Tag

ChDrive Left(strDirectory, 1)
ChDir strDirectory
Application.Dialogs(xlDialogSaveAs).Show

End Sub
 
B

Bob Phillips

Nothing obvious, it works okay for me. Are you sure Tag is set for both
controls?

Have you debugged what Tag is on entering the macros?

Also, ChDrive strDirectory is good enough, you don't need Left..

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
G

Guest

Hi RP

I guess I should have made it simpler in the first
instance, was being a bit lazy I guess. Even when the
code is as simple as below my open works, but not my
SaveAs, I take it this works for you?

Sub FileOpenDirectory()
ChDrive "C"
ChDir "C:\1"
Application.Dialogs(xlDialogOpen).Show

End Sub
Sub FileSaveAsDirectory()

ChDrive "C"
ChDir "C:\1"
Application.Dialogs(xlDialogSaveAs).Show

End Sub


Thanks

S
 
B

Bob Phillips

Yes, that is the sort of thing I did in my test, and although I didn't have
a number directory name, but having just done so, it works for me.

Bob
 

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