Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro in template opens last saved document

I created a custom toolbar with two buttons. One button adds a blank ro
to the spreadsheet with proper formatting and the other removes a row.
I assigned a macro to each button. The problem is when I open th
template to create a new spreadsheet and click either of the buttons i
tries to open the last saved document created by this template to ru
the macro from. The custom toolbar is attached to the template. When
assign the macro to the button it is referenced as AddNewRow. After
create one document from the template and save then create a ne
template, that new template custom toolbar button is referencin
'C:\Documents and Settings\.....\test.xls'!addnewrow. Any thoughts?

Code:

Sub AddNewRow()
'

'Dim Row_Count As Integer
Dim pswrd
Dim QtyCell As String
Dim msg
Dim myRow As String

myRow = ActiveCell.Row
Range("B" & myRow).Select
If Not Selection.Interior.ColorIndex = xlNone Then
msg = "You've chosen to add a row in a locked area. " & Chr(13
& _
"Please select a different area to insert a row then tr
again."
response = MsgBox(msg, vbCritical)
GoTo 100
End If

pswrd = ""
ActiveSheet.Unprotect pswrd
'Row_Count = InputBox("Enter number of rows required.")
'Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(Row_Count - 1
0)).EntireRow.Insert
Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(0
0)).EntireRow.Insert
'myRow = ActiveCell.Row
'Range("B" & myRow).Select
Range(Selection, Selection.Offset(0, 4)).Select
Selection.Interior.ColorIndex = xlNone
Selection.RowHeight = 12.75
Selection.Locked = False
Selection.FormulaHidden = False
Selection.Borders(xlDiagonalDown).LineStyle = xlNone 'next many line
are for border formatting
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

With Selection.Font
.Name = "Arial"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 1
End With

Selection.Font.Bold = False
ActiveCell.Select
QtyCell = ActiveCell.Address
With Selection
.NumberFormat = "General"
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
'.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With

ActiveCell.Offset(0, 2).HorizontalAlignment = xlLeft 'des
alignment
ActiveCell.Offset(0, 2).WrapText = True 'desc wra
text
ActiveCell.Offset(0, 3).NumberFormat = "$#,##0.00"
'ListCell = ActiveCell.Offset(0, 3).Address
ActiveCell.Offset(0, 4).NumberFormat = "$#,##0.00"
ActiveCell.Offset(0, 4).Formula = "=" & QtyCell & "*"
ActiveCell.Offset(0, 3).Address

ActiveSheet.Protect pswrd, True, True, True
'
100 End Su

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro in template opens last saved document

I'm using excel 200

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro in template opens last saved document

Save the workbook with your functions in it as an add-in (.xla) and the
use ToolsAdd-ins to add the functions permanently..

--
Message posted from http://www.ExcelForum.com

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
"Document Not Saved" Saving File Created from Template PLEASEHELP!!!! Pamela[_3_] Excel Discussion (Misc queries) 1 February 5th 09 07:42 AM
Creating a macro to print the date a document was last saved. Judi Excel Discussion (Misc queries) 2 December 30th 08 08:17 PM
Document not saved at the end of macro Vinod[_2_] Excel Discussion (Misc queries) 1 September 22nd 08 06:34 PM
saved worksheet opens in new with macro error report margaret Excel Worksheet Functions 0 April 19th 06 11:56 AM
help creating a macro in excel that opens a specific word document Prohock Excel Discussion (Misc queries) 3 March 30th 06 04:58 PM


All times are GMT +1. The time now is 09:06 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"