Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA trouble when using Excel 2003 vs Excel 2002

I cannot use a template that has worked for excel 2000 and excel 2002 when i
switch to excel 2003. The template is used to format a worksheet with
proper headers and footers and tab names based on the input received through
a text box.

The first problem: The textbox is not working. Meaning - when i type
something in the textbox on a form and hit OK, the vba error checking comes
up and says that there is a "COMPILE ERROR: Can't find project or library".
This happens in the SecNum = TextBox1.Value part

The second problem: I have a BeforePrint routine that will place headers
and footers in the document. When I try to do a print preview, I get the
same message at the point where I try to specify Chr(10) as a carriage
return.

What can be happening here? I have included the VBA code...

Problem 1 code
'---------------------------------------------------------------------------
---
Private Sub CommandButton1_Click()
SecNum = TextBox1.Value
NumShts = 5

NumShts = Worksheets.Count
J = 65
For i = 1 To NumShts
origtext = Sheets(i).Range("A1").Value
If origtext = "" Then
GoTo endline
Else
NewText = "Exhibit " & SecNum & "-" & Chr(J)
Sheets(i).Range("a1").Value = NewText
Sheets(i).Name = SecNum & "-" & Chr(J)
J = J + 1
End If
endline: Next i

UserForm1.Hide
Sheets(1).Select
End Sub

Private Sub CommandButton2_Click()
UserForm1.Hide
End Sub

Private Sub Label3_Click()

End Sub
'---------------------------------------------------------------------------
---


Problem 2 code
'---------------------------------------------------------------------------
--------
Private Sub Workbook_BeforePrint(Cancel As Boolean)
With ActiveSheet.PageSetup
.LeftFooter = "&8" & ActiveWorkbook.FullName & Chr(10) & "&D &T"
.RightFooter = "&""ZapfHumnst Ult BT,Ultra Bold""Company Name"
.RightHeader = "&A &P"
End With
End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If SaveAsUI = True Then Sheets("<---LastPage").Range("F18").Value = 1
End Sub

Private Sub Workbook_Open()
If Sheets("<---LastPage").Range("F18").Value = 0 Then UserForm1.Show
End Sub
'---------------------------------------------------------------------------
------------





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA trouble when using Excel 2003 vs Excel 2002

in the VBE, make the workbook with the code the active project (select it in
the project explorer). Go to Tools=References in the menu and see if you
have any references shown at the top as MISSING.

If so, you need to either find the referenced file on your computer, or
remove the reference if your are not using it.

--
Regards,
Tom Ogilvy

"Steven Parker" wrote in message
...
I cannot use a template that has worked for excel 2000 and excel 2002 when

i
switch to excel 2003. The template is used to format a worksheet with
proper headers and footers and tab names based on the input received

through
a text box.

The first problem: The textbox is not working. Meaning - when i type
something in the textbox on a form and hit OK, the vba error checking

comes
up and says that there is a "COMPILE ERROR: Can't find project or

library".
This happens in the SecNum = TextBox1.Value part

The second problem: I have a BeforePrint routine that will place headers
and footers in the document. When I try to do a print preview, I get the
same message at the point where I try to specify Chr(10) as a carriage
return.

What can be happening here? I have included the VBA code...

Problem 1 code

'---------------------------------------------------------------------------
---
Private Sub CommandButton1_Click()
SecNum = TextBox1.Value
NumShts = 5

NumShts = Worksheets.Count
J = 65
For i = 1 To NumShts
origtext = Sheets(i).Range("A1").Value
If origtext = "" Then
GoTo endline
Else
NewText = "Exhibit " & SecNum & "-" & Chr(J)
Sheets(i).Range("a1").Value = NewText
Sheets(i).Name = SecNum & "-" & Chr(J)
J = J + 1
End If
endline: Next i

UserForm1.Hide
Sheets(1).Select
End Sub

Private Sub CommandButton2_Click()
UserForm1.Hide
End Sub

Private Sub Label3_Click()

End Sub

'---------------------------------------------------------------------------
---


Problem 2 code

'---------------------------------------------------------------------------
--------
Private Sub Workbook_BeforePrint(Cancel As Boolean)
With ActiveSheet.PageSetup
.LeftFooter = "&8" & ActiveWorkbook.FullName & Chr(10) & "&D &T"
.RightFooter = "&""ZapfHumnst Ult BT,Ultra Bold""Company Name"
.RightHeader = "&A &P"
End With
End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If SaveAsUI = True Then Sheets("<---LastPage").Range("F18").Value = 1
End Sub

Private Sub Workbook_Open()
If Sheets("<---LastPage").Range("F18").Value = 0 Then UserForm1.Show
End Sub

'---------------------------------------------------------------------------
------------







  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 98
Default VBA trouble when using Excel 2003 vs Excel 2002

Tom:

Why is this happening? I notice this issue quite frequently here, and am wondering if MS
blew it when they released Excel 2003. This kind of reverse compatibility issue should not
happen in a well designed upgrade, should it?

Best

John Baker

"Tom Ogilvy" wrote:

in the VBE, make the workbook with the code the active project (select it in
the project explorer). Go to Tools=References in the menu and see if you
have any references shown at the top as MISSING.

If so, you need to either find the referenced file on your computer, or
remove the reference if your are not using it.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble with XY Scatter graphs Excel 2003/Office 2003 optomist1 Excel Discussion (Misc queries) 0 September 1st 09 10:07 PM
Trouble when trying to open a file excel 2007 in excel 2003 Martin Excel Discussion (Misc queries) 3 January 30th 09 02:05 PM
Trouble downloading KB918419 for Excel 2003 Huntress Excel Discussion (Misc queries) 2 August 29th 06 01:40 AM
trouble with Excel 2003 and dde flarsen Excel Discussion (Misc queries) 0 February 15th 06 07:53 PM
Trouble w/ ActiveX Controls (no userform) Excel 2002. Chris Excel Programming 2 November 14th 03 06:36 PM


All times are GMT +1. The time now is 11:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"