Solved

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

Posted on 2008-10-06
2
898 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.

749 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