Solved

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

Posted on 2008-10-06
2
888 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
ID: 22682335
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
ID: 31503356
Thanks, that works perfect for me. Your solution is excactly, what I was looking for. Great!
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

860 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