#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default File in Use

Hello everyone. I have a excel file that can be downloaded from my site. The
sheet contains a macro that runs onload and a button that calls the same
macro (if the user wants to run it again) they all run fine as long as the
user actually saves the file to his comp. If the user just says to open the
file the onload macro runs fine once, but when the button that runs the same
macro again is clicked the user recieves a file in use error, if they select
to run the read only version the macro cannot be found and then the vb stops
and you receive a error to debug or end. Is there anyway to stops this. I
really, really need some help to figure this one out as soons as possible.
Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default File in Use

How about forcing a save by putting code like this at the beginning of that
macro:

If Len(ThisWorkbook.Path) = 0 Then
MsgBox "You will need to save this file somewhere first!", _
vbExclamation, _
"running macro"
Exit Sub
End If

RBS


"Armando" wrote in message
...
Hello everyone. I have a excel file that can be downloaded from my site.
The
sheet contains a macro that runs onload and a button that calls the same
macro (if the user wants to run it again) they all run fine as long as the
user actually saves the file to his comp. If the user just says to open
the
file the onload macro runs fine once, but when the button that runs the
same
macro again is clicked the user recieves a file in use error, if they
select
to run the read only version the macro cannot be found and then the vb
stops
and you receive a error to debug or end. Is there anyway to stops this. I
really, really need some help to figure this one out as soons as possible.
Thanks in advance.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default File in Use



"RB Smissaert" wrote:

How about forcing a save by putting code like this at the beginning of that
macro:

If Len(ThisWorkbook.Path) = 0 Then
MsgBox "You will need to save this file somewhere first!", _
vbExclamation, _
"running macro"
Exit Sub
End If

RBS


"Armando" wrote in message
...
Hello everyone. I have a excel file that can be downloaded from my site.
The
sheet contains a macro that runs onload and a button that calls the same
macro (if the user wants to run it again) they all run fine as long as the
user actually saves the file to his comp. If the user just says to open
the
file the onload macro runs fine once, but when the button that runs the
same
macro again is clicked the user recieves a file in use error, if they
select
to run the read only version the macro cannot be found and then the vb
stops
and you receive a error to debug or end. Is there anyway to stops this. I
really, really need some help to figure this one out as soons as possible.
Thanks in advance.


Thanks for the advice, I really appreciate it. But is there anyway to allow the macros to run without forceing a save?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default File in Use

Not the way your code is written.
It is expecting something that involves a save.
Rewrite your code so this requirement is no longer applies.

NickHK

"Armando" wrote in message
...


"RB Smissaert" wrote:

How about forcing a save by putting code like this at the beginning of

that
macro:

If Len(ThisWorkbook.Path) = 0 Then
MsgBox "You will need to save this file somewhere first!", _
vbExclamation, _
"running macro"
Exit Sub
End If

RBS


"Armando" wrote in message
...
Hello everyone. I have a excel file that can be downloaded from my

site.
The
sheet contains a macro that runs onload and a button that calls the

same
macro (if the user wants to run it again) they all run fine as long as

the
user actually saves the file to his comp. If the user just says to

open
the
file the onload macro runs fine once, but when the button that runs

the
same
macro again is clicked the user recieves a file in use error, if they
select
to run the read only version the macro cannot be found and then the vb
stops
and you receive a error to debug or end. Is there anyway to stops

this. I
really, really need some help to figure this one out as soons as

possible.
Thanks in advance.


Thanks for the advice, I really appreciate it. But is there anyway to

allow the macros to run without forceing a save?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default File in Use

Hopefully this will help you guys look at what's going on. The code that I am
using creates a command button and assigns my macro(Opt) to the button. The
code is performed onload because the tab is created by a query, so the button
cannot just be created on the excel template and assigned the macro.
Hopefully looking at the code my help you guys help me. Once again thanks a
lot everyone for your help.

Code:

Public Sub AddButtonToSheet()

Dim oFormatSelection As Object
Dim rFormatActive As Range
Dim sCaption As String
Set oFormatSelection = Selection

' checks to see if a button was already created
If Worksheets("Report Data").Shapes.Count 0 Then
Exit Sub
End If

' creates the format options button, since the report data tab does not
exist in the template
If TypeName(oFormatSelection) = "Range" Then _
Set rFormatActive = ActiveCell
Application.ScreenUpdating = False
With Worksheets("Report Data").Shapes.AddFormControl( _
xlButtonControl, 0, 31, 150, 18)
..ControlFormat.PrintObject = False
With .TextFrame.Characters.Font
..Name = "Arial"
..FontStyle = "Regular"
..Size = 10
..ColorIndex = 0
..Shadow = False
End With
..Select
Selection.OnAction = "Opt"
sCaption = " Format Options "
If Len(sCaption) 0 Then _
Selection.Caption = sCaption
Selection.AutoSize = False
Selection.Placement = xlFreeFloating
End With
oFormatSelection.Select
If Not rFormatActive Is Nothing Then rFormatActive.Activate
Application.ScreenUpdating = True

End Sub


"NickHK" wrote:

Not the way your code is written.
It is expecting something that involves a save.
Rewrite your code so this requirement is no longer applies.

NickHK

"Armando" wrote in message
...


"RB Smissaert" wrote:

How about forcing a save by putting code like this at the beginning of

that
macro:

If Len(ThisWorkbook.Path) = 0 Then
MsgBox "You will need to save this file somewhere first!", _
vbExclamation, _
"running macro"
Exit Sub
End If

RBS


"Armando" wrote in message
...
Hello everyone. I have a excel file that can be downloaded from my

site.
The
sheet contains a macro that runs onload and a button that calls the

same
macro (if the user wants to run it again) they all run fine as long as

the
user actually saves the file to his comp. If the user just says to

open
the
file the onload macro runs fine once, but when the button that runs

the
same
macro again is clicked the user recieves a file in use error, if they
select
to run the read only version the macro cannot be found and then the vb
stops
and you receive a error to debug or end. Is there anyway to stops

this. I
really, really need some help to figure this one out as soons as

possible.
Thanks in advance.

Thanks for the advice, I really appreciate it. But is there anyway to

allow the macros to run without forceing a save?



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
File:1 and File:2 -- Double Files when Opening One File dallin Excel Discussion (Misc queries) 1 January 25th 07 02:53 AM
I saved file A over file B. Can I get file B back? Lynn Excel Discussion (Misc queries) 2 May 12th 06 11:24 AM
opening an excel file opens a duplicate file of the same file skm Excel Discussion (Misc queries) 1 December 7th 05 05:52 PM
I SAVED A FILE OVER ANOTHER A FILE IN EXCEL. THE OLD FILE WAS AN . DUFFER8MCD Excel Discussion (Misc queries) 1 December 23rd 04 11:32 PM
i received a file that reads powerpoint document file file exten. CCAROLACEREC Excel Discussion (Misc queries) 1 December 4th 04 05:02 PM


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