Need help Finishing Code

R

Rob

I'm trying to get information from my shapes as they are double-clicked but
I'm having problems.

Here's what I have so far...

Sub Open_PDF()
Dim strPDFPath As String
strPDFPath = "z:\Documentation\PDFs\"
Dim strIEPath As String
strIEPath = "C:\program files\internet explorer\iexplore.exe"
Dim strExtension As String
strExtension = ".pdf"
Dim varPropDWG As Variant
Dim varPropREV As Variant
Dim varPropREVShort As Variant
Dim vsoShape As Shape
Dim vsoCell As Visio.Cell

varPropPDF = "Ref_000639" ' This needs to be the Value of Prop.PDF --
I placed this Drawing Number in Manually for testing purposes only
----- I've also tried using varPropPDF = vsoShape.CellsSRC(3, 2, 5)
varPropREV = "Rev B2" ' This needs to be the Value of Prop.REV --
I placed this Drawing Rev in Manually for testing purposes only
----- I've also tried using varPropREV = vsoShape.CellsSRC(3, 8, 5)
varPropREVShort = Right(varPropREV, Len(varPropREV) - 4) ' Cut the
First Four Characters from the Value of Prop.REV since it is not needed

If varPropREVShort = "-" Then
Shell strIEPath & " " & strPDFPath & varPropDWG & "_" &
strExtension, vbNormalFocus
Else
Shell strIEPath & " " & strPDFPath & varPropDWG & "_" &
varPropREVShort & strExtension, vbNormalFocus
End If

End Sub

But when I try it I always get the same error below...

Runtime Error '91':
Object variable or With block variable not set


Any Help Would be Awesome.
Thanks In Advance,
Rob
 
A

Al Edlund

without going into the code I would suspect it is something like this

' create the script shell environment
Set wsh = CreateObject("wscript.shell")

' now execute the command that we built
wsh.Run (strCommand)
 
R

Rob

OK I tried that but now I get a runtime error '5':

This is how I used it....

Sub Open_PDF()
Dim strPDFPath As String
strPDFPath = "\\Amtiscpub1\public\5.CONFIGURATION_MANAGEMENT\Chameleon
Projects\!Baseline - HMMWV 1014Build\"
Dim strIEPath As String
strIEPath = "C:\program files\internet explorer\iexplore.exe"
Dim strExtension As String
strExtension = ".pdf"
Dim varPropPDF As Variant
Dim varPropREV As Variant
Dim varPropREVShort As Variant
Dim vsoShape As Shape
Dim vsoCell As Visio.Cell

' create the script shell environment
Set wsh = CreateObject("wscript.shell")

varPropPDF = vsoShape.CellsSRC(3, 2, 5) '"Ref_006B200" ' This needs to
be the Value of Prop.PDF -- I placed this Number in Manually for testing
purposes only
varPropREV = vsoShape.CellsSRC(3, 8, 5) '"Rev B2" ' This needs to
be the Value of Prop.REV -- I placed this Rev in Manually for testing
purposes only
varPropREVShort = Right(varPropREV, Len(varPropREV) - 4) ' Cut the
First Four Characters from the Value of Prop.REV since it is not needed

If varPropREVShort = "-" Then
wsh.Run Shell(strIEPath & " " & strPDFPath & varPropPDF & "_" &
strExtension), vbNormalFocus
Else
wsh.Run Shell(strIEPath & " " & strPDFPath & varPropPDF & "_" &
varPropREVShort & strExtension), vbNormalFocus
End If

End Sub

Thanks Much,
Rob
 
A

Al Edlund

dim teststr as string
teststr = "abc", or whatever

first you make sure your command works in a dos command window
open a window and test "abc"

then build the string with your variables and dump it to a msgbox until it
mirrors what you want

then testing the string inside the shell
wsh.run(teststr)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top