Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Do not copy code from template

Hello.

I have a template that has code attached to it as follows:

Private Sub Workbook_Open()

Application.DisplayAlerts = True

UpdateLinks = xlUpdateLinksAlways


Call openfile
Application.AskToUpdateLinks = False


End Sub

Private Sub openfile()

Dim sDailyReport As String
Dim vFileName As Variant

ChDrive "K"
ChDir "K:\Individual Directories\Woodford, Cathy\Daily Report"
filetoopen = Application.GetOpenFileName("Excel Files (*.xls), *.xls")
If filetoopen < False Then
Workbooks.Open FileName:=filetoopen
Else
MsgBox "User Clicked Cancel, Exiting"
Exit Sub
End If

ActiveWindow.WindowState = xlMinimized
ActiveWindow.WindowState = xlMaximized
Sheets(1).Cells(1, 1).Value = filetoopen

End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)

Dim ws As Worksheet

For Each ws In Worksheets
With ws.Cells
.Copy
.PasteSpecial xlPasteValues
End With
Next ws

Application.CutCopyMode = False


End Sub


What this does is when the user double clicks the template icon, the
template opens and then the open dialog opens so the user can select a file
to take values from to populate the template. I don't want an open diaglog
box to open when the user saves it as a .xls file, which means I have to get
rid of the code somehow. Any suggestions?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Do not copy code from template

Private Sub Workbook_Open()

Application.DisplayAlerts = True

UpdateLinks = xlUpdateLinksAlways


if thisWorkbook.Path = "" then Call openfile
Application.AskToUpdateLinks = False


End Sub

Might be what you want.

--
Regards,
Tom Ogilvy



"Cathy W" wrote in message
...
Hello.

I have a template that has code attached to it as follows:

Private Sub Workbook_Open()

Application.DisplayAlerts = True

UpdateLinks = xlUpdateLinksAlways


Call openfile
Application.AskToUpdateLinks = False


End Sub

Private Sub openfile()

Dim sDailyReport As String
Dim vFileName As Variant

ChDrive "K"
ChDir "K:\Individual Directories\Woodford, Cathy\Daily Report"
filetoopen = Application.GetOpenFileName("Excel Files (*.xls), *.xls")
If filetoopen < False Then
Workbooks.Open FileName:=filetoopen
Else
MsgBox "User Clicked Cancel, Exiting"
Exit Sub
End If

ActiveWindow.WindowState = xlMinimized
ActiveWindow.WindowState = xlMaximized
Sheets(1).Cells(1, 1).Value = filetoopen

End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)

Dim ws As Worksheet

For Each ws In Worksheets
With ws.Cells
.Copy
.PasteSpecial xlPasteValues
End With
Next ws

Application.CutCopyMode = False


End Sub


What this does is when the user double clicks the template icon, the
template opens and then the open dialog opens so the user can select a

file
to take values from to populate the template. I don't want an open

diaglog
box to open when the user saves it as a .xls file, which means I have to

get
rid of the code somehow. Any suggestions?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Do not copy code from template

Thank you soooooo much! That worked wonderful! If you lived in Newfoundland,
I would bake you some cookies! Thanks again and have a great Christmas!

Cathy

"Tom Ogilvy" wrote:

Private Sub Workbook_Open()

Application.DisplayAlerts = True

UpdateLinks = xlUpdateLinksAlways


if thisWorkbook.Path = "" then Call openfile
Application.AskToUpdateLinks = False


End Sub

Might be what you want.

--
Regards,
Tom Ogilvy



"Cathy W" wrote in message
...
Hello.

I have a template that has code attached to it as follows:

Private Sub Workbook_Open()

Application.DisplayAlerts = True

UpdateLinks = xlUpdateLinksAlways


Call openfile
Application.AskToUpdateLinks = False


End Sub

Private Sub openfile()

Dim sDailyReport As String
Dim vFileName As Variant

ChDrive "K"
ChDir "K:\Individual Directories\Woodford, Cathy\Daily Report"
filetoopen = Application.GetOpenFileName("Excel Files (*.xls), *.xls")
If filetoopen < False Then
Workbooks.Open FileName:=filetoopen
Else
MsgBox "User Clicked Cancel, Exiting"
Exit Sub
End If

ActiveWindow.WindowState = xlMinimized
ActiveWindow.WindowState = xlMaximized
Sheets(1).Cells(1, 1).Value = filetoopen

End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)

Dim ws As Worksheet

For Each ws In Worksheets
With ws.Cells
.Copy
.PasteSpecial xlPasteValues
End With
Next ws

Application.CutCopyMode = False


End Sub


What this does is when the user double clicks the template icon, the
template opens and then the open dialog opens so the user can select a

file
to take values from to populate the template. I don't want an open

diaglog
box to open when the user saves it as a .xls file, which means I have to

get
rid of the code somehow. Any suggestions?




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
Opening a template .xls with VBA code IXLINXL Excel Programming 5 December 1st 04 08:05 PM
Code to copy range vs Copy Entire Worksheet - can't figure it out Mike Taylor Excel Programming 1 April 15th 04 08:34 PM
Adding new worksheet from template in code E.J. van Wijngaarden Excel Programming 2 April 9th 04 03:15 AM
Excel template-run code on open Cindy Excel Programming 0 January 28th 04 04:19 PM
Check my code to use template? Ed[_9_] Excel Programming 1 July 23rd 03 03:04 AM


All times are GMT +1. The time now is 11:58 PM.

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"