View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
ARbitOUR[_21_] ARbitOUR[_21_] is offline
external usenet poster
 
Posts: 1
Default Autorun macro does not autorun...


Simon Lloyd;461616 Wrote:
The line that you stated is re-opening the workbook ISN'T!, the
workbook, if it meets criteria is ACTIVATED well before that, the fact
that you

Code:
--------------------
Set DatabaseWB = Workbooks.Open(......

--------------------
doesn't mean it that it is opening it, it is

simply setting a variable to be used instead of typing the whole thing
it would be used like

Code:
--------------------

Set DatabaseWB = Workbooks.Open(ThisWorkbook.Path & "\HC Price Lists.xlsm")
If Range("A1").Value = "Y" Then
DatabaseWB
End If

--------------------


If the workbook is indeed closed then you must trigger the reopen!


Hi Simon,

First of, thx for the response.

you concluded your reply with "If the workbook is indeed closed then
you must trigger the reopen!"

The following code checks to see if it is already open...if it is open
it is activated, if it isn't, then is opens the workbook....


For Each DatabaseWB In Workbooks
If DatabaseWB.Name = "HC Price Lists.xlsm" Then
DatabaseWB.Activate
If ActiveWorkbook.ReadOnly = True Then
ActiveWorkbook.Close SaveChanges:=False
Else
Application.DisplayAlerts = False
ActiveWorkbook.Close SaveChanges:=True
Application.DisplayAlerts = True
End If
Else
End If
Next


You will notice that the code tests whether the workbook in the sample
code is already open, if it is, then it is activated, if it isn't then
it is opened. There are NO other code in the macro to open the indicated
workbook only the line that you say does not open the workbook.....as
said yourself, it is a conditional opening of the workbook...(why open
it if it is already open right?)

either way, in hindsight I see that the sample code I posted was
actually the code where the 'cut/copy' macro works as it should (the
sample code is linked to a button control, when pressed, it opens the
price list database 'HC Price Lists' as it should (i.e with cut/copy
disabled).....So I accidentally posted the code that doesn't have the
problem. The code with the problem (i.e where the 'cut/copy' macro
doesn't function when 're-opening' via a macro - yet functioning
correctly when opened manualy) are as follows:

Private Sub SAMPLECODE_Click()

Dim NewQuote As Workbook
Set NewQuote = Workbooks.Open(ThisWorkbook.Path & "Quote.xlsm")

End Sub

EXACTLY THE SAME METHOD AS IN THE SAMPLE CODE WHERE IT WORKS! (only
difference is the workbook names aren't the same)

The code above opens the file 'Quote.xlsm' which ASLO contains the
'disable cut/copy' macro...yet in this case it doesn't work (cut/copy
isn't disabled when the above code is triggered).

Yet, when the first set of sample code is triggered (opening a
different workbook...the price list database...) the 'disable cut/copy'
code DOES execute....!!!???

Oh..the torture and misery!

PLEASE HELP?


--
ARbitOUR
------------------------------------------------------------------------
ARbitOUR's Profile: http://www.thecodecage.com/forumz/member.php?userid=254
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=127677