VBscript browse help

December 1, 2009 at 08:44:02
Specs: Windows XP
Can someone help with vbscript.
Right now I have a working script that compares 2 files, problem is
you have to put in the exact path to both files. I would like to browse
for both files. here is the working script..

Dim objWord
Dim objScript
Dim strDocA
Dim strDocB
Dim fContinue
'Const vbExclamation = 48

strDocA = InputBox("Enter most recent HC Path & Filename", "Path to HC File")
strDocB = InputBox("Enter previous HC Path & Filename", "Path to HC File")

' Assume that user passed valid paths
fContinue = True

' Now, test file paths to DocA and DocB for validity
' -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Set objScript = CreateObject("Scripting.FileSystemObject")
fContinue = objScript.FileExists(strDocA)
fContinue = objScript.FileExists(strDocB)
Set objScript = Nothing

If fContinue = False Then
MsgBox "Wrong Path to File - Come on!" ,vbExclamation ,"Error"
Else
' Only continue if user has typed text into InputBox.
Set objWord = CreateObject("Word.Application")

objWord.Documents.Open strDocA
objWord.ActiveDocument.Compare strDocB
objWord.Visible = True

Set objWord = Nothing
End If

----
I was playing around with the browse function. here is what i have so far.
does not work.

Dim objWord
Dim objScript
Dim strDocA
Dim strDocB
Dim fContinue
Dim MyMsga
Dim MyMsgb
Set objFSO = CreateObject("UserAccounts.CommonDialog")
objFSO.Filter = "All Files|*.*"

'Const vbExclamation = 48

MyMsga = MsgBox ("Choose most recent HC File", 0, "Browse for HC File")
objFSO = ObjFSO.ShowOpen


MyMsgb = MsgBox ("Choose Last month HC File", 0, "Browse for HC File")
Set ObjFSO = CreateObject("UserAccounts.CommonDialog")

objFSO = ObjFSO.ShowOpen

' Assume that user passed valid paths
fContinue = True

' Now, test file paths to DocA and DocB for validity
' -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Set objScript = CreateObject("Scripting.FileSystemObject")
fContinue = objScript.FileExists(strDocA)
fContinue = objScript.FileExists(strDocB)
Set objScript = Nothing

If fContinue = False Then
MsgBox "Wrong Path to File - Come on!" ,vbExclamation ,"Error"
Else
' Only continue if user has typed text into InputBox.
Set objWord = CreateObject("Word.Application")


objWord.Documents.Open strDocA
objWord.ActiveDocument.Compare strDocB
objWord.Visible = True

Set objWord = Nothing
End If

can someone help ?

thanks.


See More: VBscript browse help

Report •


#1
December 2, 2009 at 05:11:15
no one can help ?

Report •

#2
December 3, 2009 at 08:19:19
no one can help ?
I can, but don't expect me to not be a jerk about it.

Set objFSO = CreateObject("UserAccounts.CommonDialog")
objFSO = ObjFSO.ShowOpen
Set ObjFSO = CreateObject("UserAccounts.CommonDialog")
objFSO = ObjFSO.ShowOpen

So you're (re)assigning the variable objFSO (a name that implies it's a FileScriptingObject, but I'll let that slide) 4 times, and you expect it to remember each of those old values.... why?

fContinue = objScript.FileExists(strDocA)
fContinue = objScript.FileExists(strDocB)

You never define strDocA nor strDocB

Set objWord = CreateObject("Word.Application")
Word has its own open file dialog; whereas UserAccounts.CommonDialog will not work with Vista nor Win7. Use Word's dialog instead.


Report •

Related Solutions


Ask Question