Old VB Project doesn't work with New Office or Windows 7 
Author Message
 Old VB Project doesn't work with New Office or Windows 7

Is there anyone that can recommend a solution to 'fix' an old VB application?
It's a report card program that uses a Word template and fills in the word
document from this .exe file created in VB. I have no idea how to debug as I
am not the one who programmed it nor do I know antything more than beginner
basic. It appears to be a very simple program and the folder consists of a
few .bas files, .frx, and .frm files. I downloaded Visual Studio Pro to debug
the .exe file, but I don't know where to begin.

Problem:

The program asks you to open the word document(Which it does), but when you
click the tabs with the form, it tells me the document is not open. I
attempted to look at the code, and I think the error is coming from around
this area:
------------------------------------------------------------------------------------------------
'Global CONNECTED As Boolean 'flag if word document is opened correctly
Sub InitializeName()
'need err handler here
On Error GoTo errorinit

FirstName = wrdapp.ActiveDocument.FormFields("FFtxtFirstname").Result
'On Error GoTo errorinit
LastName = wrdapp.ActiveDocument.FormFields("FFtxtLastName").Result

errorinit:
If Err.Number <> 0 Then
'"Number " & Err.Number & vbCrLf &
'MsgBox Err.Description & vbCrLf & "file not opened correctly"
Err.Clear
MsgBox "There was an error reading the student's name" & vbCrLf & "Please
make sure you have opened a Report Card Word File and the name has been
entered correctly."
FirstName = ""
LastName = ""
'wrdapp.Application.Quit
Exit Sub
End If
'Exit Sub
'Resume Next '?
End Sub
Sub PageLength()
Dim PageCount As Integer
Dim response As Integer
'On Error GoTo errorhandler
On Error Resume Next
PageCount =
wrdapp.ActiveDocument.ComputeStatistics(Statistic:=wdStatisticPages)
If Err.Number <> 0 Then
   'WordwasNotRunning = True
    Err.Clear   ' Clear Err object in case error occurred.
    'MsgBox "The Word document for your student " & FirstName & " is not
open. "
    Exit Sub
End If
If PageCount <> 2 Then
response = MsgBox("report is longer than two pages and will not print
correctly. ", vbCritical, "REPORT TOO LONG!")
End If
'errorhandler:
'MsgBox "Student file is not opened correctly"
'Exit Sub
'Resume

End Sub
'Public Sub AddHScroll(List As ListBox)
  '  Dim i As Integer, intGreatestLen As Integer, lngGreatestWidth As Long
  '  'Find Longest Text in Listbox

    'For i = 0 To List.ListCount - 1
       ' If Len(List.List(i)) > Len(List.List(intGreatestLen)) Then
           ' intGreatestLen = i
       ' End If
   ' Next i
  '  'Get Twips
  '  lngGreatestWidth = List.Parent.TextWidth(List.List(intGreatestLen) +
Space(1))
   ' 'Space(1) is used to prevent the last Ch
   ' '     aracter from being cut off
   ' 'Convert to Pixels
   ' lngGreatestWidth = lngGreatestWidth \ Screen.TwipsPerPixelX
   ' 'Use api to add scrollbar
   ' SendMessage List.hWnd, LB_SETHORIZONTALEXTENT, lngGreatestWidth, 0
    'End Sub

Sub TestLength(Section As String)
Dim LC As Integer
'set font size to 12
'On Error GoTo errorhandler

On Error Resume Next
wrdapp.Application.Windows(namedoc).Activate

If Err.Number <> 0 Then
   'WordwasNotRunning = True
    Err.Clear   ' Clear Err object in case error occurred.
    MsgBox "The Word document for your student " & FirstName & " is not
open. " & vbCrLf & "Please open using File - Open "
    frmTab.Caption = "Report Card Writer" & " - No student file open"
    FirstName = ""
    LastName = ""
    namedoc = ""
    frmTab.staRC.SimpleText = "No student's file is open.  Open a student's
file using File - Open or see Help for creating new student's file"

    Exit Sub
----------------------------------------------------------------------------------------------

...because the message I keep getting is "The Word document for your student
{studentname} is not open." I then try to open

So for some reason, the .exe file thinks Word is not open. What's weird is
that this program works on some XP machines with Office 2003 installed. Some
other PC's running XP and Office 2003 don't work with the error descibed
above. When I install on a Windows 7 and Office 2010, I get pretty much the
same error. I really want to get this program to run.

It must have to do with the link between Office and the .exe file.

-JoeF



Mon, 21 Jan 2013 07:14:06 GMT  
 Old VB Project doesn't work with New Office or Windows 7
Top posted:

What version of VB was the code originally written is, or what version are
you attempting to load the code up in?

Where are the location of the Word files you are attempting to open?

Win7 has stricter rules about file IO that in XP...so before I can take a
closer look at this, I would need to know some of these things.

- Kev


: Is there anyone that can recommend a solution to 'fix' an old VB
application?
: It's a report card program that uses a Word template and fills in the word
: document from this .exe file created in VB. I have no idea how to debug as
I
: am not the one who programmed it nor do I know antything more than
beginner
: basic. It appears to be a very simple program and the folder consists of a
: few .bas files, .frx, and .frm files. I downloaded Visual Studio Pro to
debug
: the .exe file, but I don't know where to begin.
:
: Problem:
:
: The program asks you to open the word document(Which it does), but when
you
: click the tabs with the form, it tells me the document is not open. I
: attempted to look at the code, and I think the error is coming from around
: this area:
: ------------------------------------------------------------------------------------------------
: 'Global CONNECTED As Boolean 'flag if word document is opened correctly
: Sub InitializeName()
: 'need err handler here
: On Error GoTo errorinit
:
: FirstName = wrdapp.ActiveDocument.FormFields("FFtxtFirstname").Result
: 'On Error GoTo errorinit
: LastName = wrdapp.ActiveDocument.FormFields("FFtxtLastName").Result
:
: errorinit:
: If Err.Number <> 0 Then
: '"Number " & Err.Number & vbCrLf &
: 'MsgBox Err.Description & vbCrLf & "file not opened correctly"
: Err.Clear
: MsgBox "There was an error reading the student's name" & vbCrLf & "Please
: make sure you have opened a Report Card Word File and the name has been
: entered correctly."
: FirstName = ""
: LastName = ""
: 'wrdapp.Application.Quit
: Exit Sub
: End If
: 'Exit Sub
: 'Resume Next '?
: End Sub
: Sub PageLength()
: Dim PageCount As Integer
: Dim response As Integer
: 'On Error GoTo errorhandler
: On Error Resume Next
: PageCount =
: wrdapp.ActiveDocument.ComputeStatistics(Statistic:=wdStatisticPages)
: If Err.Number <> 0 Then
:   'WordwasNotRunning = True
:    Err.Clear   ' Clear Err object in case error occurred.
:    'MsgBox "The Word document for your student " & FirstName & " is not
: open. "
:    Exit Sub
: End If
: If PageCount <> 2 Then
: response = MsgBox("report is longer than two pages and will not print
: correctly. ", vbCritical, "REPORT TOO LONG!")
: End If
: 'errorhandler:
: 'MsgBox "Student file is not opened correctly"
: 'Exit Sub
: 'Resume
:
: End Sub
: 'Public Sub AddHScroll(List As ListBox)
:  '  Dim i As Integer, intGreatestLen As Integer, lngGreatestWidth As Long
:  '  'Find Longest Text in Listbox
:
:    'For i = 0 To List.ListCount - 1
:       ' If Len(List.List(i)) > Len(List.List(intGreatestLen)) Then
:           ' intGreatestLen = i
:       ' End If
:   ' Next i
:  '  'Get Twips
:  '  lngGreatestWidth = List.Parent.TextWidth(List.List(intGreatestLen) +
: Space(1))
:   ' 'Space(1) is used to prevent the last Ch
:   ' '     aracter from being cut off
:   ' 'Convert to Pixels
:   ' lngGreatestWidth = lngGreatestWidth \ Screen.TwipsPerPixelX
:   ' 'Use api to add scrollbar
:   ' SendMessage List.hWnd, LB_SETHORIZONTALEXTENT, lngGreatestWidth, 0
:    'End Sub
:
: Sub TestLength(Section As String)
: Dim LC As Integer
: 'set font size to 12
: 'On Error GoTo errorhandler
:
: On Error Resume Next
: wrdapp.Application.Windows(namedoc).Activate
:
: If Err.Number <> 0 Then
:   'WordwasNotRunning = True
:    Err.Clear   ' Clear Err object in case error occurred.
:    MsgBox "The Word document for your student " & FirstName & " is not
: open. " & vbCrLf & "Please open using File - Open "
:    frmTab.Caption = "Report Card Writer" & " - No student file open"
:    FirstName = ""
:    LastName = ""
:    namedoc = ""
:    frmTab.staRC.SimpleText = "No student's file is open.  Open a student's
: file using File - Open or see Help for creating new student's file"
:
:    Exit Sub
: ----------------------------------------------------------------------------------------------
:
: ...because the message I keep getting is "The Word document for your
student
: {studentname} is not open." I then try to open
:
: So for some reason, the .exe file thinks Word is not open. What's weird is
: that this program works on some XP machines with Office 2003 installed.
Some
: other PC's running XP and Office 2003 don't work with the error descibed
: above. When I install on a Windows 7 and Office 2010, I get pretty much
the
: same error. I really want to get this program to run.
:
: It must have to do with the link between Office and the .exe file.
:
: -JoeF



Mon, 21 Jan 2013 08:39:00 GMT  
 Old VB Project doesn't work with New Office or Windows 7
Thanks for the reply...I believe it was VB 6. I'm using Notepad to look at
the code currently. I downloaded Visual Studio Pro 2010 to attempt debugging
the .exe file...but I'm so far removed from this stuff.

I found a .pdm file that references Visual Studio\VB98...
I found a .vbp file that shows:

==================================================================================================================================
Type=Exe
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\WINDOWS\System32\stdole2.tlb#OLE Automation
Reference=*\G{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}#2.0#0#..\..\..\..\..\Program
Files\Common Files\Microsoft Shared\Office10\MSO.DLL#Microsoft Office 8.0
Object Library
Reference=*\G{00020905-0000-0000-C000-000000000046}#8.0#409#..\..\..\..\..\Program
Files\Microsoft Office\Office10\MSWORD.OLB#Microsoft Word 8.0 Object Library
Form=frmEngCognitive.frm
Reference=*\G{00025E01-0000-0000-C000-000000000046}#5.0#0#..\..\..\..\..\Program
Files\Common Files\Microsoft Shared\DAO\dao360.dll#Microsoft DAO 3.6 Object
Library
Module=Module1; Report Card Module.bas
Form=frmEngLanguage.frm
Reference=*\G{0D452EE1-E08F-101A-852E-02608C4D0BB4}#2.0#0#..\..\..\..\..\WINDOWS\System32\FM20.DLL#Microsoft Forms 2.0 Object Library
Form=frmEngSocial.frm
Form=frmSpanCognitive2.frm
Form=frmSpanLanguage.frm
Form=frmPT.frm
Form=frmOT.frm
Form=frmAbout.frm
Designer=frmEditTextTeachers.frm
Object={BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0; TABCTL32.OCX
Reference=*\G{3D5C6BF0-69A3-11D0-B393-00A0C9055D8E}#1.0#0#..\..\..\..\..\Program
Files\Common Files\designer\MSDERUN.DLL#Microsoft Data Environment Instance
1.0 (SP4)
Reference=*\G{00000205-0000-0010-8000-00AA006D2EA4}#2.5#0#..\..\..\..\..\Program
Files\Common Files\system\ado\msado25.tlb#Microsoft ActiveX Data Objects 2.5
Library
Form=frmTab.frm
Module=Modulept; ModulePT.bas
Designer=frmEngSelfHelp.frm
Designer=frmEngFM.frm
Designer=frmSpanFM.frm
Designer=frmSpanSelfHelp.frm
Designer=frmSpanSocial.frm
Form=frmSplash.frm
Form=frmHelp.frm
Form=frmSpeech5Ps.frm
Module=ModuleSpeech; ModuleSpeech.bas
Module=ModuleOT; ModuleOT.bas
Form=frmSpeechMainEnglish.frm
Object={831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0; MSCOMCTL.OCX
Module=ModuleTeacherSection; ModuleTeacherSection.bas
Form=frmCounselingEng.frm
Module=ModuleCounseling; ModuleCounseling.bas
Class=comdlg; comdlg.cls
Startup="Sub Main"
HelpFile=""
Title="report card"
Command32=""
Name="ReportCard"
HelpContextID="0"
CompatibleMode="0"
MajorVer=1
MinorVer=0
RevisionVer=0
AutoIncrementVer=0
ServerSupportFiles=0
VersionCompanyName=""
CompilationType=0
OptimizationType=0
FavorPentiumPro(tm)=0
CodeViewDebugInfo=0
NoAliasing=0
BoundsCheck=0
OverflowCheck=0
FlPointCheck=0
FDIVCheck=0
UnroundedFP=0
StartMode=0
Unattended=0
Retained=0
ThreadPerObject=0
MaxNumberOfThreads=1
DebugStartupOption=0

[MS Transaction Server]
AutoRefresh=1
==============================================

Quote:

> Top posted:

> What version of VB was the code originally written is, or what version are
> you attempting to load the code up in?

> Where are the location of the Word files you are attempting to open?

> Win7 has stricter rules about file IO that in XP...so before I can take a
> closer look at this, I would need to know some of these things.

> - Kev



> : Is there anyone that can recommend a solution to 'fix' an old VB
> application?
> : It's a report card program that uses a Word template and fills in the word
> : document from this .exe file created in VB. I have no idea how to debug as
> I
> : am not the one who programmed it nor do I know antything more than
> beginner
> : basic. It appears to be a very simple program and the folder consists of a
> : few .bas files, .frx, and .frm files. I downloaded Visual Studio Pro to
> debug
> : the .exe file, but I don't know where to begin.
> :
> : Problem:
> :
> : The program asks you to open the word document(Which it does), but when
> you
> : click the tabs with the form, it tells me the document is not open. I
> : attempted to look at the code, and I think the error is coming from around
> : this area:
> : ------------------------------------------------------------------------------------------------
> : 'Global CONNECTED As Boolean 'flag if word document is opened correctly
> : Sub InitializeName()
> : 'need err handler here
> : On Error GoTo errorinit
> :
> : FirstName = wrdapp.ActiveDocument.FormFields("FFtxtFirstname").Result
> : 'On Error GoTo errorinit
> : LastName = wrdapp.ActiveDocument.FormFields("FFtxtLastName").Result
> :
> : errorinit:
> : If Err.Number <> 0 Then
> : '"Number " & Err.Number & vbCrLf &
> : 'MsgBox Err.Description & vbCrLf & "file not opened correctly"
> : Err.Clear
> : MsgBox "There was an error reading the student's name" & vbCrLf & "Please
> : make sure you have opened a Report Card Word File and the name has been
> : entered correctly."
> : FirstName = ""
> : LastName = ""
> : 'wrdapp.Application.Quit
> : Exit Sub
> : End If
> : 'Exit Sub
> : 'Resume Next '?
> : End Sub
> : Sub PageLength()
> : Dim PageCount As Integer
> : Dim response As Integer
> : 'On Error GoTo errorhandler
> : On Error Resume Next
> : PageCount =
> : wrdapp.ActiveDocument.ComputeStatistics(Statistic:=wdStatisticPages)
> : If Err.Number <> 0 Then
> :   'WordwasNotRunning = True
> :    Err.Clear   ' Clear Err object in case error occurred.
> :    'MsgBox "The Word document for your student " & FirstName & " is not
> : open. "
> :    Exit Sub
> : End If
> : If PageCount <> 2 Then
> : response = MsgBox("report is longer than two pages and will not print
> : correctly. ", vbCritical, "REPORT TOO LONG!")
> : End If
> : 'errorhandler:
> : 'MsgBox "Student file is not opened correctly"
> : 'Exit Sub
> : 'Resume
> :
> : End Sub
> : 'Public Sub AddHScroll(List As ListBox)
> :  '  Dim i As Integer, intGreatestLen As Integer, lngGreatestWidth As Long
> :  '  'Find Longest Text in Listbox
> :
> :    'For i = 0 To List.ListCount - 1
> :       ' If Len(List.List(i)) > Len(List.List(intGreatestLen)) Then
> :           ' intGreatestLen = i
> :       ' End If
> :   ' Next i
> :  '  'Get Twips
> :  '  lngGreatestWidth = List.Parent.TextWidth(List.List(intGreatestLen) +
> : Space(1))
> :   ' 'Space(1) is used to prevent the last Ch
> :   ' '     aracter from being cut off
> :   ' 'Convert to Pixels
> :   ' lngGreatestWidth = lngGreatestWidth \ Screen.TwipsPerPixelX
> :   ' 'Use api to add scrollbar
> :   ' SendMessage List.hWnd, LB_SETHORIZONTALEXTENT, lngGreatestWidth, 0
> :    'End Sub
> :
> : Sub TestLength(Section As String)
> : Dim LC As Integer
> : 'set font size to 12
> : 'On Error GoTo errorhandler
> :
> : On Error Resume Next
> : wrdapp.Application.Windows(namedoc).Activate
> :
> : If Err.Number <> 0 Then
> :   'WordwasNotRunning = True
> :    Err.Clear   ' Clear Err object in case error occurred.
> :    MsgBox "The Word document for your student " & FirstName & " is not
> : open. " & vbCrLf & "Please open using File - Open "
> :    frmTab.Caption = "Report Card Writer" & " - No student file open"
> :    FirstName = ""
> :    LastName = ""
> :    namedoc = ""
> :    frmTab.staRC.SimpleText = "No student's file is open.  Open a student's
> : file using File - Open or see Help for creating new student's file"
> :
> :    Exit Sub
> : ----------------------------------------------------------------------------------------------
> :
> : ...because the message I keep getting is "The Word document for your
> student
> : {studentname} is not open." I then try to open
> :
> : So for some reason, the .exe file thinks Word is not open. What's weird is
> : that this program works on some XP machines with Office 2003 installed.
> Some
> : other PC's running XP and Office 2003 don't work with the error descibed
> : above. When I install on a Windows 7 and Office 2010, I get pretty much
> the
> : same error. I really want to get this program to run.
> :
> : It must have to do with the link between Office and the .exe file.
> :
> : -JoeF

> .



Mon, 21 Jan 2013 11:10:03 GMT  
 Old VB Project doesn't work with New Office or Windows 7

: Thanks for the reply...I believe it was VB 6. I'm using Notepad to look at
: the code currently. I downloaded Visual Studio Pro 2010 to attempt
debugging
: the .exe file...but I'm so far removed from this stuff.

NO!!!! STOP!!!!

Code written in VB6 will not compile or even work in VS 2010.  And even if
you make it work, you'll have a several hundred megabyte runtime issue you
don't want to deal with, especially if you are dealing with multiple
machines all with varying OSs.

Do you have VB 5 or 6 to work with?  I am going to do my best to help save
this project for you...but be aware we have an ongoing (and mostly ugly)
debate about VB6 and what MSFT calls VB.NET.  They are not the same thing
(and watch the amount of replies I get from this point forward telling me I
am wrong and why .NET is the way of the future, blah, blah, blah.  All
opinions.  The truth in your scenario is using VB.Net or VS 2010, you will
have to rewrite your project from the ground up, if you choose that route.
All the "upgrade wizards" in the world are still going to leave you with a
significant amount of work based on what I've seen so far.  There is no
getting around that, especially if you are a novice programmer.

If you do not have access to VB 5 or 6, then I will work with you to fix
this issue, as I suspect it requires a tweak or two to be compatible with
Win 7.  It will be quicker and easier than rewriting in a different
language, even tho it bears the same name.  And I certainly won't let the
folks in this community who preach all things .NET push you into their web
community.

My email is kevin [dot] provance [at] tpasoft [dot] com.  Send me an email
so I can get some more detailed information from you, and help you avoid the
flame war that's probably going to break out over the language debate in the
next day or so.  Even if it means running your project on my Win 7 box to
find the error, we can fix this fairly quickly without a rewrite.

Write me and let me know!

- Kevin



Mon, 21 Jan 2013 14:20:50 GMT  
 Old VB Project doesn't work with New Office or Windows 7

Quote:
> Is there anyone that can recommend a solution to 'fix' an old VB application?
> It's a report card program that uses a Word template and fills in the word
> document from this .exe file created in VB. I have no idea how to debug as I
> am not the one who programmed it nor do I know antything more than beginner
> basic. It appears to be a very simple program and the folder consists of a
> few .bas files, .frx, and .frm files. I downloaded Visual Studio Pro to debug
> the .exe file, but I don't know where to begin.

It's probably better to ask this in a Word programming group or forum.
While most of us have the experience and can help with generic VB6, your
problem seems to be specific to the use of Word.

--

i-Catcher Development Team

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)



Mon, 21 Jan 2013 15:26:05 GMT  
 Old VB Project doesn't work with New Office or Windows 7
Did you already tried to run the the program as administrator?  (right click
on it and then runas ....)

That is the most given error in other forums and newsgroups if it is
unrecognizable and windows 7


Quote:
> Is there anyone that can recommend a solution to 'fix' an old VB
> application?
> It's a report card program that uses a Word template and fills in the word
> document from this .exe file created in VB. I have no idea how to debug as
> I
> am not the one who programmed it nor do I know antything more than
> beginner
> basic. It appears to be a very simple program and the folder consists of a
> few .bas files, .frx, and .frm files. I downloaded Visual Studio Pro to
> debug
> the .exe file, but I don't know where to begin.

> Problem:

> The program asks you to open the word document(Which it does), but when
> you
> click the tabs with the form, it tells me the document is not open. I
> attempted to look at the code, and I think the error is coming from around
> this area:
> ------------------------------------------------------------------------------------------------
> 'Global CONNECTED As Boolean 'flag if word document is opened correctly
> Sub InitializeName()
> 'need err handler here
> On Error GoTo errorinit

> FirstName = wrdapp.ActiveDocument.FormFields("FFtxtFirstname").Result
> 'On Error GoTo errorinit
> LastName = wrdapp.ActiveDocument.FormFields("FFtxtLastName").Result

> errorinit:
> If Err.Number <> 0 Then
> '"Number " & Err.Number & vbCrLf &
> 'MsgBox Err.Description & vbCrLf & "file not opened correctly"
> Err.Clear
> MsgBox "There was an error reading the student's name" & vbCrLf & "Please
> make sure you have opened a Report Card Word File and the name has been
> entered correctly."
> FirstName = ""
> LastName = ""
> 'wrdapp.Application.Quit
> Exit Sub
> End If
> 'Exit Sub
> 'Resume Next '?
> End Sub
> Sub PageLength()
> Dim PageCount As Integer
> Dim response As Integer
> 'On Error GoTo errorhandler
> On Error Resume Next
> PageCount =
> wrdapp.ActiveDocument.ComputeStatistics(Statistic:=wdStatisticPages)
> If Err.Number <> 0 Then
>   'WordwasNotRunning = True
>    Err.Clear   ' Clear Err object in case error occurred.
>    'MsgBox "The Word document for your student " & FirstName & " is not
> open. "
>    Exit Sub
> End If
> If PageCount <> 2 Then
> response = MsgBox("report is longer than two pages and will not print
> correctly. ", vbCritical, "REPORT TOO LONG!")
> End If
> 'errorhandler:
> 'MsgBox "Student file is not opened correctly"
> 'Exit Sub
> 'Resume

> End Sub
> 'Public Sub AddHScroll(List As ListBox)
>  '  Dim i As Integer, intGreatestLen As Integer, lngGreatestWidth As Long
>  '  'Find Longest Text in Listbox

>    'For i = 0 To List.ListCount - 1
>       ' If Len(List.List(i)) > Len(List.List(intGreatestLen)) Then
>           ' intGreatestLen = i
>       ' End If
>   ' Next i
>  '  'Get Twips
>  '  lngGreatestWidth = List.Parent.TextWidth(List.List(intGreatestLen) +
> Space(1))
>   ' 'Space(1) is used to prevent the last Ch
>   ' '     aracter from being cut off
>   ' 'Convert to Pixels
>   ' lngGreatestWidth = lngGreatestWidth \ Screen.TwipsPerPixelX
>   ' 'Use api to add scrollbar
>   ' SendMessage List.hWnd, LB_SETHORIZONTALEXTENT, lngGreatestWidth, 0
>    'End Sub

> Sub TestLength(Section As String)
> Dim LC As Integer
> 'set font size to 12
> 'On Error GoTo errorhandler

> On Error Resume Next
> wrdapp.Application.Windows(namedoc).Activate

> If Err.Number <> 0 Then
>   'WordwasNotRunning = True
>    Err.Clear   ' Clear Err object in case error occurred.
>    MsgBox "The Word document for your student " & FirstName & " is not
> open. " & vbCrLf & "Please open using File - Open "
>    frmTab.Caption = "Report Card Writer" & " - No student file open"
>    FirstName = ""
>    LastName = ""
>    namedoc = ""
>    frmTab.staRC.SimpleText = "No student's file is open.  Open a student's
> file using File - Open or see Help for creating new student's file"

>    Exit Sub
> ----------------------------------------------------------------------------------------------

> ...because the message I keep getting is "The Word document for your
> student
> {studentname} is not open." I then try to open

> So for some reason, the .exe file thinks Word is not open. What's weird is
> that this program works on some XP machines with Office 2003 installed.
> Some
> other PC's running XP and Office 2003 don't work with the error descibed
> above. When I install on a Windows 7 and Office 2010, I get pretty much
> the
> same error. I really want to get this program to run.

> It must have to do with the link between Office and the .exe file.

> -JoeF



Tue, 22 Jan 2013 00:42:02 GMT  
 Old VB Project doesn't work with New Office or Windows 7
Thank you for the replies...I have found the problem, but not sure how to
resolve...

When logged in to the computer as CLASSROOM, the report card program works.
When logged in as ADMIN, the report card program does not work.

-       Within Windows 7, I installed something called XP MODE, which is a virtual
XP environment running inside of Windows 7.
-       I installed Microsoft Office 2003 Professional inside of XP Mode.
-       I installed the report card application using the instructions provided by
its creator.
o       When attempting to run the report card application, it would fail with the
same errors Ive explained in the past.
-       After seeing that the program runs as CLASSROOM(Explained above), I
created a new user called CLASSROOM and logged in.
-       I installed the report card application using the instructions provided by
its creator, this time under the CLASSROOM user.
o       The report card application worked!!!!!!!!
-       This was great news, because now I know the path to the files are hard
coded into the report card program. I now need to duplicate the CLASSROOM
user environment.

Heres the bad news

-       The default path to the documents folder changed when going from XP to
Vista/Windows 7.
o       XP uses C:\Documents and Settings\username\Documents
o       Vista/Windows 7 uses C:\Users\username\Documents
-       The report card program has the XP path hard coded into the
executable(Reportcard.exe) application.
o       Windows Vista and 7 use a junction point "Documents and Settings" which is
hidden. This is supposed to re-route old programs to the new location, but it
does not successfully do this with this report card app.

I tried to create the directory "Documents and Settings" on the C: drive
within Windows7, but can't.

Windows 7 uses the path C:\users\{username}\documents. Is there any way to
find these paths in the report card application and recompile with new paths?

Quote:

> Is there anyone that can recommend a solution to 'fix' an old VB application?
> It's a report card program that uses a Word template and fills in the word
> document from this .exe file created in VB. I have no idea how to debug as I
> am not the one who programmed it nor do I know antything more than beginner
> basic. It appears to be a very simple program and the folder consists of a
> few .bas files, .frx, and .frm files. I downloaded Visual Studio Pro to debug
> the .exe file, but I don't know where to begin.

> Problem:

> The program asks you to open the word document(Which it does), but when you
> click the tabs with the form, it tells me the document is not open. I
> attempted to look at the code, and I think the error is coming from around
> this area:
> ------------------------------------------------------------------------------------------------
> 'Global CONNECTED As Boolean 'flag if word document is opened correctly
> Sub InitializeName()
> 'need err handler here
> On Error GoTo errorinit

> FirstName = wrdapp.ActiveDocument.FormFields("FFtxtFirstname").Result
> 'On Error GoTo errorinit
> LastName = wrdapp.ActiveDocument.FormFields("FFtxtLastName").Result

> errorinit:
> If Err.Number <> 0 Then
> '"Number " & Err.Number & vbCrLf &
> 'MsgBox Err.Description & vbCrLf & "file not opened correctly"
> Err.Clear
> MsgBox "There was an error reading the student's name" & vbCrLf & "Please
> make sure you have opened a Report Card Word File and the name has been
> entered correctly."
> FirstName = ""
> LastName = ""
> 'wrdapp.Application.Quit
> Exit Sub
> End If
> 'Exit Sub
> 'Resume Next '?
> End Sub
> Sub PageLength()
> Dim PageCount As Integer
> Dim response As Integer
> 'On Error GoTo errorhandler
> On Error Resume Next
> PageCount =
> wrdapp.ActiveDocument.ComputeStatistics(Statistic:=wdStatisticPages)
> If Err.Number <> 0 Then
>    'WordwasNotRunning = True
>     Err.Clear   ' Clear Err object in case error occurred.
>     'MsgBox "The Word document for your student " & FirstName & " is not
> open. "
>     Exit Sub
> End If
> If PageCount <> 2 Then
> response = MsgBox("report is longer than two pages and will not print
> correctly. ", vbCritical, "REPORT TOO LONG!")
> End If
> 'errorhandler:
> 'MsgBox "Student file is not opened correctly"
> 'Exit Sub
> 'Resume

> End Sub
> 'Public Sub AddHScroll(List As ListBox)
>   '  Dim i As Integer, intGreatestLen As Integer, lngGreatestWidth As Long
>   '  'Find Longest Text in Listbox

>     'For i = 0 To List.ListCount - 1
>        ' If Len(List.List(i)) > Len(List.List(intGreatestLen)) Then
>            ' intGreatestLen = i
>        ' End If
>    ' Next i
>   '  'Get Twips
>   '  lngGreatestWidth = List.Parent.TextWidth(List.List(intGreatestLen) +
> Space(1))
>    ' 'Space(1) is used to prevent the last Ch
>    ' '     aracter from being cut off
>    ' 'Convert to Pixels
>    ' lngGreatestWidth = lngGreatestWidth \ Screen.TwipsPerPixelX
>    ' 'Use api to add scrollbar
>    ' SendMessage List.hWnd, LB_SETHORIZONTALEXTENT, lngGreatestWidth, 0
>     'End Sub

> Sub TestLength(Section As String)
> Dim LC As Integer
> 'set font size to 12
> 'On Error GoTo errorhandler

> On Error Resume Next
> wrdapp.Application.Windows(namedoc).Activate

> If Err.Number <> 0 Then
>    'WordwasNotRunning = True
>     Err.Clear   ' Clear Err object in case error occurred.
>     MsgBox "The Word document for your student " & FirstName & " is not
> open. " & vbCrLf & "Please open using File - Open "
>     frmTab.Caption = "Report Card Writer" & " - No student file open"
>     FirstName = ""
>     LastName = ""
>     namedoc = ""
>     frmTab.staRC.SimpleText = "No student's file is open.  Open a student's
> file using File - Open or see Help for creating new student's file"

>     Exit Sub
> ----------------------------------------------------------------------------------------------

> ...because the message I keep getting is "The Word document for your student
> {studentname} is not open." I then try to open

> So for some reason, the .exe file thinks Word is not open. What's weird is
> that this program works on some XP machines with Office 2003 installed. Some
> other PC's running XP and Office 2003 don't work with the error descibed
> above. When I install on a Windows 7 and Office 2010, I get pretty much the
> same error. I really want to get this program to run.

> It must have to do with the link between Office and the .exe file.

> -JoeF



Tue, 22 Jan 2013 00:45:03 GMT  
 Old VB Project doesn't work with New Office or Windows 7


:
: Windows 7 uses the path C:\users\{username}\documents. Is there any way to
: find these paths in the report card application and recompile with new
paths?

Yes, but we need to be clear on something.  If you are still using VS 2010
or any version of VB with dot net in the name, you'll need to ask in the
appropriate forum as this NG is for VB6 and lower.

http://vbnet.mvps.org/code/browse/csidl.htm



Tue, 22 Jan 2013 01:19:48 GMT  
 Old VB Project doesn't work with New Office or Windows 7
Yes...that's what makes it run....but the Word file can't remain open when
you attempt to run the report card app.
Quote:

> Did you already tried to run the the program as administrator?  (right click
> on it and then runas ....)

> That is the most given error in other forums and newsgroups if it is
> unrecognizable and windows 7



> > Is there anyone that can recommend a solution to 'fix' an old VB
> > application?
> > It's a report card program that uses a Word template and fills in the word
> > document from this .exe file created in VB. I have no idea how to debug as
> > I
> > am not the one who programmed it nor do I know antything more than
> > beginner
> > basic. It appears to be a very simple program and the folder consists of a
> > few .bas files, .frx, and .frm files. I downloaded Visual Studio Pro to
> > debug
> > the .exe file, but I don't know where to begin.

> > Problem:

> > The program asks you to open the word document(Which it does), but when
> > you
> > click the tabs with the form, it tells me the document is not open. I
> > attempted to look at the code, and I think the error is coming from around
> > this area:
> > ------------------------------------------------------------------------------------------------
> > 'Global CONNECTED As Boolean 'flag if word document is opened correctly
> > Sub InitializeName()
> > 'need err handler here
> > On Error GoTo errorinit

> > FirstName = wrdapp.ActiveDocument.FormFields("FFtxtFirstname").Result
> > 'On Error GoTo errorinit
> > LastName = wrdapp.ActiveDocument.FormFields("FFtxtLastName").Result

> > errorinit:
> > If Err.Number <> 0 Then
> > '"Number " & Err.Number & vbCrLf &
> > 'MsgBox Err.Description & vbCrLf & "file not opened correctly"
> > Err.Clear
> > MsgBox "There was an error reading the student's name" & vbCrLf & "Please
> > make sure you have opened a Report Card Word File and the name has been
> > entered correctly."
> > FirstName = ""
> > LastName = ""
> > 'wrdapp.Application.Quit
> > Exit Sub
> > End If
> > 'Exit Sub
> > 'Resume Next '?
> > End Sub
> > Sub PageLength()
> > Dim PageCount As Integer
> > Dim response As Integer
> > 'On Error GoTo errorhandler
> > On Error Resume Next
> > PageCount =
> > wrdapp.ActiveDocument.ComputeStatistics(Statistic:=wdStatisticPages)
> > If Err.Number <> 0 Then
> >   'WordwasNotRunning = True
> >    Err.Clear   ' Clear Err object in case error occurred.
> >    'MsgBox "The Word document for your student " & FirstName & " is not
> > open. "
> >    Exit Sub
> > End If
> > If PageCount <> 2 Then
> > response = MsgBox("report is longer than two pages and will not print
> > correctly. ", vbCritical, "REPORT TOO LONG!")
> > End If
> > 'errorhandler:
> > 'MsgBox "Student file is not opened correctly"
> > 'Exit Sub
> > 'Resume

> > End Sub
> > 'Public Sub AddHScroll(List As ListBox)
> >  '  Dim i As Integer, intGreatestLen As Integer, lngGreatestWidth As Long
> >  '  'Find Longest Text in Listbox

> >    'For i = 0 To List.ListCount - 1
> >       ' If Len(List.List(i)) > Len(List.List(intGreatestLen)) Then
> >           ' intGreatestLen = i
> >       ' End If
> >   ' Next i
> >  '  'Get Twips
> >  '  lngGreatestWidth = List.Parent.TextWidth(List.List(intGreatestLen) +
> > Space(1))
> >   ' 'Space(1) is used to prevent the last Ch
> >   ' '     aracter from being cut off
> >   ' 'Convert to Pixels
> >   ' lngGreatestWidth = lngGreatestWidth \ Screen.TwipsPerPixelX
> >   ' 'Use api to add scrollbar
> >   ' SendMessage List.hWnd, LB_SETHORIZONTALEXTENT, lngGreatestWidth, 0
> >    'End Sub

> > Sub TestLength(Section As String)
> > Dim LC As Integer
> > 'set font size to 12
> > 'On Error GoTo errorhandler

> > On Error Resume Next
> > wrdapp.Application.Windows(namedoc).Activate

> > If Err.Number <> 0 Then
> >   'WordwasNotRunning = True
> >    Err.Clear   ' Clear Err object in case error occurred.
> >    MsgBox "The Word document for your student " & FirstName & " is not
> > open. " & vbCrLf & "Please open using File - Open "
> >    frmTab.Caption = "Report Card Writer" & " - No student file open"
> >    FirstName = ""
> >    LastName = ""
> >    namedoc = ""
> >    frmTab.staRC.SimpleText = "No student's file is open.  Open a student's
> > file using File - Open or see Help for creating new student's file"

> >    Exit Sub
> > ----------------------------------------------------------------------------------------------

> > ...because the message I keep getting is "The Word document for your
> > student
> > {studentname} is not open." I then try to open

> > So for some reason, the .exe file thinks Word is not open. What's weird is
> > that this program works on some XP machines with Office 2003 installed.
> > Some
> > other PC's running XP and Office 2003 don't work with the error descibed
> > above. When I install on a Windows 7 and Office 2010, I get pretty much
> > the
> > same error. I really want to get this program to run.

> > It must have to do with the link between Office and the .exe file.

> > -JoeF

> .



Tue, 22 Jan 2013 01:28:03 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. old code - new browser - code doesn't work

2. Windows XP Style Manifest doesn't work on ActiveX Control Projects

3. Windows Service Calling VB6 dll doesn't work but works with VB6

4. Application runs with Windows 95/NT, but doesn't work with Windows 98

5. Old modules doesn't work!

6. Help!: VB control (OCX) doesn't work in Word for Windows

7. Application.Filesearch doesn't work in Office XP

8. Debugger doesn't work on Macros for Word in Office XP

9. KeyPreview doesn't work for F1 in Office Web Components

10. DoEvents doesn't work with DHTML projects.

11. Old Old VB To New VB

12. fRefreshLinks Doesn't work if path doesn't exist

 

 
Powered by phpBB® Forum Software