Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.newusers
houweipeng houweipeng is offline
external usenet poster
 
Posts: 1
Default How can I get the valid full name, before I call .Documents.Open() method

Before I call Documents.Open() method, I want to know if the doc's full name
is invalid in any OS(eg, English os, JPN, CN).

  #2   Report Post  
Posted to microsoft.public.word.newusers
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default How can I get the valid full name, before I call .Documents.Open() method

houweipeng wrote:
Before I call Documents.Open() method, I want to know if the doc's
full name is invalid in any OS(eg, English os, JPN, CN).


Don't bother with writing a parser for file names -- that already exists in
Windows. Just include an On Error statement that will redirect the macro's
execution to an error handler if the name is invalid.

Dim MyFileName As String
MyFileName = "X:\bad path\possibly invalid filename.doc"

On Error GoTo BadFileName
Documents.Open(MyFileName)
' rest of the macro...

Exit Sub

BadFileName:
MsgBox MyFileName & " is not valid"


--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.


Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
open document with full page Grant Page Layout 1 May 13th 06 09:16 AM
Unable to see full file name in Recently open documents on file me Sparky56 New Users 0 February 6th 06 03:44 PM
How open attatchment that says "not a valid single file web page" Ninhhoa1 Microsoft Word Help 1 January 21st 06 08:02 AM
Couldnt open filename.txt because it didnt contain valid databas Dinesh Mailmerge 2 October 26th 05 03:48 PM
'document or path name is not valid' when trying to open word doc gorbichof Microsoft Word Help 4 August 29th 05 06:52 AM


All times are GMT +1. The time now is 06:18 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"