Setting a SaveAs Directory

D

Dodger Jim

I want to open a SaveAs dialog box to a specific directory. I cannot find a
setting that allows me to control the directory. Is there anything in VBA
that will let me control the directory in which this dialog box will open?
Thanks!
 
H

Helmut Weber

Hi Dodger Jim,

like this:

Dim oDlg As Dialog
Set oDlg = Dialogs(wdDialogFileSaveAs)
With oDlg
.Name = "c:\test\" ' the directory
.Show
End With

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
D

Dodger Jim

Helmut -
This did not work. The SaveAs dialog box opened, but not to the directory I
specified with .Name =.

When I type the . before typing Name, the drop-down menu of choices does not
include Name. Also, the drive and directory I'm designating are on a LAN.
Does this matter?
 
H

Helmut Weber

Hi Dodger Jim,

did you try it including the closing backslash?

Works fine here and now.
Otherwise, someboby else, who knows better, might join.

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
D

Dodger Jim

The first time I tried it with the backslash - didn't work. When you
mentioned that, I tried it without - and it worked! Now, on to the next
problem! Thanks for your help!
 
D

Dodger Jim

Like I said - next problem! How can I set the file type in the dialog box to
..doc? It keeps coming up to .dot because my initial document is a template.
 
H

Helmut Weber

Hi Jim,

try adding
.Format = wdFormatTemplate

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 
D

Dodger Jim

Actually, this put me on the right track:

..Format = wdFormatDocument
accomplished what I wanted to do. However -

I seem to be going from one problem to another and when I think I've got it
working, something else stops working that was previously working. I can now
get the SaveAs dialog box to come up to the correct directory and format that
I want. When I click the Run icon from within the IDE of my userform,
everything works great. It runs through all the code as it is supposed to
except of course the Document_Open routine which automatically triggers the
start of the macro.

When I open the document fresh and the Document_Open code is allowed to
trigger the start of the macro -

Private Sub Document_Open()
Load frmNewName
frmNewName.Show
End Sub

everything appears to run exactly the same UNTIL I click on the Save button
in the SaveAs dialog box. At that point, the macro stops and the original
template document opens. No Save occurs.

Why does it save a new document with the name given when I start the process
by clicking Run, but when it opens automatically, it does not save a new
document but leaves my template document open? Help??????
 
H

Helmut Weber

Hi Jim,

at that point I can't help you with an exact advice,
as I don't have all of your environment.
Though I've read several postings about similar problems,
and solved a related issue by removing most macros from
autoopen, as it seems, not before autoopen is finished,
all of the doc is completely available.

Easier said than done, of course. I used an on time macro
in autoopen, that waits some seconds and then starts
the macro, that did'nt work in autoopen itself.
Sorry, I don't have a code example At hand right now.

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 

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