Solved

How to use wdDialogFileOpen with default path and default name on the top of the dialog

Posted on 2008-10-06
2
867 Views
Last Modified: 2012-05-11
Hi,

I have implemented the function Vorlageoeffnen, which is attached, in a winword 2003 vba.

My problem:

I want to open the dialog window with a default path which should be the path of the winword application itself. My solution does not work for some reason.

Second:
It would be fine, if i could change the name in the top of the dialog from "Öffnen", or "Open" in English to a diffrent name.

Thanks for any help in advance
Public Function Vorlageoeffnen()

Dim dialOpen As Dialog

Set dialOpen = Dialogs(wdDialogFileOpen)

With dialOpen

'       .Name = Application.ActiveDocument.Path

ChangeFileOpenDirectory (Application.ActiveDocument.Path) & "\"

       .Name = "*.xls"

       .Display

       strExcelDaten = .Name

   

End With

Set doc = Application.ActiveDocument

If dialOpen.Name <> "*.xls" Then

    Ausfuellen

Else

    If doc.ProtectionType = wdNoProtection Then doc.Protect wdAllowOnlyFormFields, NoReset:=True

    Unload frmWarten

    Exit Function

End If
 

End Function

Open in new window

0
Comment
Question by:rolandkg1001
2 Comments
 
LVL 23

Accepted Solution

by:
irudyk earned 250 total points
Comment Utility
Try using the following code
Public Function Vorlageoeffnen()
 

Dim dialOpen As FileDialog

Set dialOpen = Application.FileDialog(msoFileDialogOpen)
 

With dialOpen

       ChangeFileOpenDirectory (Application.Path) & "\"

       .Title = "Öffnen"

       .ButtonName = "Öffnen"

       .FilterIndex = 2

       .AllowMultiSelect = False

       .InitialFileName = "*.xls"

       .Show

       If .SelectedItems.Count > 0 Then strExcelDaten = .SelectedItems(1)

   

End With
 

Set doc = Application.ActiveDocument

If InStr(1, strExcelDaten, ".xls", vbTextCompare) <> 0 Then

    Ausfuellen

Else

    If doc.ProtectionType = wdNoProtection Then doc.Protect wdAllowOnlyFormFields, NoReset:=True

    Unload frmWarten

    Exit Function

End If

 

End Function

Open in new window

0
 

Author Closing Comment

by:rolandkg1001
Comment Utility
Thanks, that works perfect for me. Your solution is excactly, what I was looking for. Great!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now