Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
other
informationbridge
office.intranets
office.misc
office.setup
office.xml
officeupdate
onenote
photodraw.discussion
powerpoint
producer
proj.standard&server
project
project.developer
project.pro_and_serve
project.server
project.vba
project2000
publisher
publisher.prepress
publisher.programming
publisher.webdesign
visio
visio.createshapes
visio.database.modeling
visio.dev.diagrams
visio.dev.shapesheet
visio.dev.vba
visio.dev.vc
visio.developer
visio.general
visio.installation
visio.printing
visio.software.modeling
visio.troubleshoot
  
 
date: Wed, 8 Oct 2008 06:26:03 -0700,    group: microsoft.public.project        back       


Jack heirarchy macro - adding excel formatting steps   
Hi,
I'm developing some extra coding onto the end of Jack's Heirarchy macro with 
some formatting steps so that I do not have to format the spreadsheet every 
tme i run the macro.

I have come up against a little bit of an annoyance, though, and as I'm no 
expert, would like some help in resolving it.

The first line of code I have added is:

Range("A:A").Select

The first time I run the code I get no errors. The second time I run the 
code, I get the following error:

Run Time Error '1004':
Method 'Range' of Object '_Global' failed

When I debug, the first line of my code above is highlighted.

If I end, and run a third time, it runs ok. But every alternate time I run 
the code, I get the same error.

I have selected the Excel object library reference, else it wouldn't run at 
all.

Can anyone point me towards why I get this error?

Thanks
James.
date: Wed, 8 Oct 2008 06:26:03 -0700   author:   James

Re: Jack heirarchy macro - adding excel formatting steps   
On Wed, 8 Oct 2008 06:26:03 -0700, James wrote:

> Hi,
> I'm developing some extra coding onto the end of Jack's Heirarchy macro with 
> some formatting steps so that I do not have to format the spreadsheet every 
> tme i run the macro.
> 
> I have come up against a little bit of an annoyance, though, and as I'm no 
> expert, would like some help in resolving it.
> 
> The first line of code I have added is:
> 
> Range("A:A").Select
> 
> The first time I run the code I get no errors. The second time I run the 
> code, I get the following error:
> 
> Run Time Error '1004':
> Method 'Range' of Object '_Global' failed
> 
> When I debug, the first line of my code above is highlighted.
> 
> If I end, and run a third time, it runs ok. But every alternate time I run 
> the code, I get the same error.
> 
> I have selected the Excel object library reference, else it wouldn't run at 
> all.
> 
> Can anyone point me towards why I get this error?
> 
> Thanks
> James.

You've posted to the M$ Project forum. You'll probably get better results
posting to microsoft.public.excel.programming
date: Wed, 8 Oct 2008 07:57:43 -0600   author:   salgud

Re: Jack heirarchy macro - adding excel formatting steps   
Thanks salgud,

I did wonder about posting this there originally, as the code relates to 
Excel. However, the code is written in VBA in Microsoft Project, and run from 
there, and so figured I'd only get bounced to here anyway! My thoughts were 
that it was something peculiar to running out of Project.

I'll give it a shot over there.

Thanks.
James.

"salgud" wrote:

> On Wed, 8 Oct 2008 06:26:03 -0700, James wrote:
> 
> > Hi,
> > I'm developing some extra coding onto the end of Jack's Heirarchy macro with 
> > some formatting steps so that I do not have to format the spreadsheet every 
> > tme i run the macro.
> > 
> > I have come up against a little bit of an annoyance, though, and as I'm no 
> > expert, would like some help in resolving it.
> > 
> > The first line of code I have added is:
> > 
> > Range("A:A").Select
> > 
> > The first time I run the code I get no errors. The second time I run the 
> > code, I get the following error:
> > 
> > Run Time Error '1004':
> > Method 'Range' of Object '_Global' failed
> > 
> > When I debug, the first line of my code above is highlighted.
> > 
> > If I end, and run a third time, it runs ok. But every alternate time I run 
> > the code, I get the same error.
> > 
> > I have selected the Excel object library reference, else it wouldn't run at 
> > all.
> > 
> > Can anyone point me towards why I get this error?
> > 
> > Thanks
> > James.
> 
> You've posted to the M$ Project forum. You'll probably get better results
> posting to microsoft.public.excel.programming
>
date: Wed, 8 Oct 2008 07:09:28 -0700   author:   James

Re: Jack heirarchy macro - adding excel formatting steps   
In article ,
 James  wrote:

> Thanks salgud,
> 
> I did wonder about posting this there originally, as the code relates to 
> Excel. However, the code is written in VBA in Microsoft Project, and run from 
> there, and so figured I'd only get bounced to here anyway! My thoughts were 
> that it was something peculiar to running out of Project.
> 
> I'll give it a shot over there.
> 
> Thanks.
> James.

James,
It might help to see more details of the code you added to Jack's macro.

John
Project MVP
> 
> "salgud" wrote:
> 
> > On Wed, 8 Oct 2008 06:26:03 -0700, James wrote:
> > 
> > > Hi,
> > > I'm developing some extra coding onto the end of Jack's Heirarchy macro 
> > > with 
> > > some formatting steps so that I do not have to format the spreadsheet 
> > > every 
> > > tme i run the macro.
> > > 
> > > I have come up against a little bit of an annoyance, though, and as I'm 
> > > no 
> > > expert, would like some help in resolving it.
> > > 
> > > The first line of code I have added is:
> > > 
> > > Range("A:A").Select
> > > 
> > > The first time I run the code I get no errors. The second time I run the 
> > > code, I get the following error:
> > > 
> > > Run Time Error '1004':
> > > Method 'Range' of Object '_Global' failed
> > > 
> > > When I debug, the first line of my code above is highlighted.
> > > 
> > > If I end, and run a third time, it runs ok. But every alternate time I 
> > > run 
> > > the code, I get the same error.
> > > 
> > > I have selected the Excel object library reference, else it wouldn't run 
> > > at 
> > > all.
> > > 
> > > Can anyone point me towards why I get this error?
> > > 
> > > Thanks
> > > James.
> > 
> > You've posted to the M$ Project forum. You'll probably get better results
> > posting to microsoft.public.excel.programming
> >
date: Wed, 08 Oct 2008 08:43:22 -0700   author:   John

Re: Jack heirarchy macro - adding excel formatting steps   
Actually, the appropriate ng would be microsoft.public.project.developer

-- 
----------
Gary L. Chefetz, MVP
MSProjectExperts
Project Server Consulting: http://www.msprojectexperts.com
Project Server Training: http://www.projectservertraining.com
Project Server FAQS: http://www.projectserverexperts.com
Project Server Help Blog: http://www.projectserverhelp.com


"salgud"  wrote in message 
news:vmy3pnnsb9m5.14zl5xcnsjeb2.dlg@40tude.net...
> On Wed, 8 Oct 2008 06:26:03 -0700, James wrote:
>
>> Hi,
>> I'm developing some extra coding onto the end of Jack's Heirarchy macro 
>> with
>> some formatting steps so that I do not have to format the spreadsheet 
>> every
>> tme i run the macro.
>>
>> I have come up against a little bit of an annoyance, though, and as I'm 
>> no
>> expert, would like some help in resolving it.
>>
>> The first line of code I have added is:
>>
>> Range("A:A").Select
>>
>> The first time I run the code I get no errors. The second time I run the
>> code, I get the following error:
>>
>> Run Time Error '1004':
>> Method 'Range' of Object '_Global' failed
>>
>> When I debug, the first line of my code above is highlighted.
>>
>> If I end, and run a third time, it runs ok. But every alternate time I 
>> run
>> the code, I get the same error.
>>
>> I have selected the Excel object library reference, else it wouldn't run 
>> at
>> all.
>>
>> Can anyone point me towards why I get this error?
>>
>> Thanks
>> James.
>
> You've posted to the M$ Project forum. You'll probably get better results
> posting to microsoft.public.excel.programming
date: Wed, 8 Oct 2008 11:57:19 -0400   author:   Gary L. Chefetz

Re: Jack heirarchy macro - adding excel formatting steps   
Hmmm...

Haven't looked at that code for a while, but I'm imagining that you are 
running this line when there is no instance of excel open.
Posting the code is the only way to know what is going on here.
And the others are correct that this should be in the 
microsoft.public.project.developer newsgroup.
-Jack

"James"  wrote in message 
news:B27CF702-94C8-4F11-8896-28DE42BE7DB8@microsoft.com...
> Hi,
> I'm developing some extra coding onto the end of Jack's Heirarchy macro 
> with
> some formatting steps so that I do not have to format the spreadsheet 
> every
> tme i run the macro.
>
> I have come up against a little bit of an annoyance, though, and as I'm no
> expert, would like some help in resolving it.
>
> The first line of code I have added is:
>
> Range("A:A").Select
>
> The first time I run the code I get no errors. The second time I run the
> code, I get the following error:
>
> Run Time Error '1004':
> Method 'Range' of Object '_Global' failed
>
> When I debug, the first line of my code above is highlighted.
>
> If I end, and run a third time, it runs ok. But every alternate time I run
> the code, I get the same error.
>
> I have selected the Excel object library reference, else it wouldn't run 
> at
> all.
>
> Can anyone point me towards why I get this error?
>
> Thanks
> James.
date: Wed, 8 Oct 2008 09:16:23 -0700   author:   Jack Dahlgren MVP

Re: Jack heirarchy macro - adding excel formatting steps   
Hi,


It could be very very simple; I've had this once
Range is also a Project object.
Try Excel.range, or use range as a property of an Excel object, see what 
happens
HTH
-- 
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
"James"  wrote in message 
news:B27CF702-94C8-4F11-8896-28DE42BE7DB8@microsoft.com...
> Hi,
> I'm developing some extra coding onto the end of Jack's Heirarchy macro 
> with
> s
ome formatting steps so that I do not have to format the spreadsheet every
> tme i run the macro.
>
> I have come up against a little bit of an annoyance, though, and as I'm no
> expert, would like some help in resolving it.
>
> The first line of code I have added is:
>
> Range("A:A").Select
>
> The first time I run the code I get no errors. The second time I run the
> code, I get the following error:
>
> Run Time Error '1004':
> Method 'Range' of Object '_Global' failed
>
> When I debug, the first line of my code above is highlighted.
>
> If I end, and run a third time, it runs ok. But every alternate time I run
> the code, I get the same error.
>
> I have selected the Excel object library reference, else it wouldn't run 
> at
> all.
>
> Can anyone point me towards why I get this error?
>
> Thanks
> James.
date: Wed, 8 Oct 2008 19:59:42 +0200   author:   Jan De Messemaeker

Re: Jack heirarchy macro - adding excel formatting steps   
Thanks Jack, John, Gary and Jan for your feedback.

I currently have this code added just before it kicks back to Project to 
show the message box.

'Delete first column
Range("A:A").Select
Selection.Delete Shift:=xlToLeft

which deletes the blank '0' column. It is the 'Range' line that kicks out 
every other time it runs.

Jack, excel is open at this  point, as your Macro has already started and 
populated a sheet with my Project data. However, the hidden "Personal.xls" is 
not open at this point. I originally created a Macro in Excel, but had to 
save, close and re-open before I could use it.

Jan, you could be right, here, and I wondered if it might be something like 
this. But why whould it work every other time it is run? If it was this, 
would it fail every time? I will try the change you suggest and see if the 
issue continues.

As to which section this should be in, I already have this same question in 
two forums here. I put it here originally as this has originated from VBA 
used in the desktop version of Project, not developer. I choose not to post 
it in the Excel board originally as I felt the problem arose due to the fact 
that the VBA coding is in MSP, and I wouldn't get the same issue if this code 
was solely in Excel.

One contributing factor could be that I am using Project 2007 with Office 
2003?

Also, when I check the references, I see V5 of the Excel object library for 
"Global.MPT", and V11 for my current project file. Should they both be V11?

Thanks for your help!

James.

"Jack Dahlgren MVP" wrote:

> Hmmm...
> 
> Haven't looked at that code for a while, but I'm imagining that you are 
> running this line when there is no instance of excel open.
> Posting the code is the only way to know what is going on here.
> And the others are correct that this should be in the 
> microsoft.public.project.developer newsgroup.
> -Jack
> 
> "James"  wrote in message 
> news:B27CF702-94C8-4F11-8896-28DE42BE7DB8@microsoft.com...
> > Hi,
> > I'm developing some extra coding onto the end of Jack's Heirarchy macro 
> > with
> > some formatting steps so that I do not have to format the spreadsheet 
> > every
> > tme i run the macro.
> >
> > I have come up against a little bit of an annoyance, though, and as I'm no
> > expert, would like some help in resolving it.
> >
> > The first line of code I have added is:
> >
> > Range("A:A").Select
> >
> > The first time I run the code I get no errors. The second time I run the
> > code, I get the following error:
> >
> > Run Time Error '1004':
> > Method 'Range' of Object '_Global' failed
> >
> > When I debug, the first line of my code above is highlighted.
> >
> > If I end, and run a third time, it runs ok. But every alternate time I run
> > the code, I get the same error.
> >
> > I have selected the Excel object library reference, else it wouldn't run 
> > at
> > all.
> >
> > Can anyone point me towards why I get this error?
> >
> > Thanks
> > James. 
>
date: Thu, 9 Oct 2008 01:12:02 -0700   author:   James

Re: Jack heirarchy macro - adding excel formatting steps   
Thanks Jan,

As per my previous reply to Jack, I have tried changing from:

Range("A:A").Select

to

Excel.Range("A:A").Select

but it still give the same run time error every second time I run the macro.

Sorry, my VBA skills are limited. How do I use range as a property of an 
Excel object?

Thanks.

"Jan De Messemaeker" wrote:

> Hi,
> 
> 
> It could be very very simple; I've had this once
> Range is also a Project object.
> Try Excel.range, or use range as a property of an Excel object, see what 
> happens
> HTH
> -- 
> Jan De Messemaeker
> Microsoft Project Most Valuable Professional
> +32 495 300 620
> For availability check:
> http://users.online.be/prom-ade/Calendar.pdf
> "James"  wrote in message 
> news:B27CF702-94C8-4F11-8896-28DE42BE7DB8@microsoft.com...
> > Hi,
> > I'm developing some extra coding onto the end of Jack's Heirarchy macro 
> > with
> > s
> ome formatting steps so that I do not have to format the spreadsheet every
> > tme i run the macro.
> >
> > I have come up against a little bit of an annoyance, though, and as I'm no
> > expert, would like some help in resolving it.
> >
> > The first line of code I have added is:
> >
> > Range("A:A").Select
> >
> > The first time I run the code I get no errors. The second time I run the
> > code, I get the following error:
> >
> > Run Time Error '1004':
> > Method 'Range' of Object '_Global' failed
> >
> > When I debug, the first line of my code above is highlighted.
> >
> > If I end, and run a third time, it runs ok. But every alternate time I run
> > the code, I get the same error.
> >
> > I have selected the Excel object library reference, else it wouldn't run 
> > at
> > all.
> >
> > Can anyone point me towards why I get this error?
> >
> > Thanks
> > James. 
> 
> 
>
date: Thu, 9 Oct 2008 01:22:00 -0700   author:   James

Re: Jack heirarchy macro - adding excel formatting steps   
The Excel library for excel 2003 should be v11, 2007 is v12.

Like Jan said, try fully qualifying the method (ie Excel.Range instead of 
Range).
The other thing to look at is whether there is a sheet which is active. With 
no active sheet the range doesn't mean anything.

-Jack Dahlgren

"James"  wrote in message 
news:E54CEF02-ABFC-4282-9EBD-C42D2902B6FB@microsoft.com...
> Thanks Jack, John, Gary and Jan for your feedback.
>
> I currently have this code added just before it kicks back to Project to
> show the message box.
>
> 'Delete first column
> Range("A:A").Select
> Selection.Delete Shift:=xlToLeft
>
> which deletes the blank '0' column. It is the 'Range' line that kicks out
> every other time it runs.
>
> Jack, excel is open at this  point, as your Macro has already started and
> populated a sheet with my Project data. However, the hidden "Personal.xls" 
> is
> not open at this point. I originally created a Macro in Excel, but had to
> save, close and re-open before I could use it.
>
> Jan, you could be right, here, and I wondered if it might be something 
> like
> this. But why whould it work every other time it is run? If it was this,
> would it fail every time? I will try the change you suggest and see if the
> issue continues.
>
> As to which section this should be in, I already have this same question 
> in
> two forums here. I put it here originally as this has originated from VBA
> used in the desktop version of Project, not developer. I choose not to 
> post
> it in the Excel board originally as I felt the problem arose due to the 
> fact
> that the VBA coding is in MSP, and I wouldn't get the same issue if this 
> code
> was solely in Excel.
>
> One contributing factor could be that I am using Project 2007 with Office
> 2003?
>
> Also, when I check the references, I see V5 of the Excel object library 
> for
> "Global.MPT", and V11 for my current project file. Should they both be 
> V11?
>
> Thanks for your help!
>
> James.
>
> "Jack Dahlgren MVP" wrote:
>
>> Hmmm...
>>
>> Haven't looked at that code for a while, but I'm imagining that you are
>> running this line when there is no instance of excel open.
>> Posting the code is the only way to know what is going on here.
>> And the others are correct that this should be in the
>> microsoft.public.project.developer newsgroup.
>> -Jack
>>
>> "James"  wrote in message
>> news:B27CF702-94C8-4F11-8896-28DE42BE7DB8@microsoft.com...
>> > Hi,
>> > I'm developing some extra coding onto the end of Jack's Heirarchy macro
>> > with
>> > some formatting steps so that I do not have to format the spreadsheet
>> > every
>> > tme i run the macro.
>> >
>> > I have come up against a little bit of an annoyance, though, and as I'm 
>> > no
>> > expert, would like some help in resolving it.
>> >
>> > The first line of code I have added is:
>> >
>> > Range("A:A").Select
>> >
>> > The first time I run the code I get no errors. The second time I run 
>> > the
>> > code, I get the following error:
>> >
>> > Run Time Error '1004':
>> > Method 'Range' of Object '_Global' failed
>> >
>> > When I debug, the first line of my code above is highlighted.
>> >
>> > If I end, and run a third time, it runs ok. But every alternate time I 
>> > run
>> > the code, I get the same error.
>> >
>> > I have selected the Excel object library reference, else it wouldn't 
>> > run
>> > at
>> > all.
>> >
>> > Can anyone point me towards why I get this error?
>> >
>> > Thanks
>> > James.
>>
date: Thu, 9 Oct 2008 09:05:47 -0700   author:   Jack Dahlgren MVP

Re: Jack heirarchy macro - adding excel formatting steps   
Thanks Jack,

When I click on my current project in the top left window and view 
references, it is V11. When I click on global and view references I only see 
V5. This is in the Project VBA session. In Excel it is V11. Given that the 
error I get references '_Global', this seems to me to be theprime culprit.

I have changed all of my Range statements into Excel.Range, but it has not 
fixed the problem.

I have not added a specific line to activate the sheet. The code follows 
directly from your heirarch macro (before it throws back to Project), and I 
always close down Excel before I run it, so I am always in the same state 
when I start.

If the problem was due to the sheet not being active, the problem would 
happen every time, wouldn't it? I have this issue every other time it starts. 
Here is the full code, including the Heirarchy macro which I have made a 
couple of tweaks to.

Sub TaskHierarchy()
Dim xlApp As  ......
.....Dim Acount As Integer

Set xlApp = New Excel.Application
xlApp.Visible = True
AppActivate "Microsoft Excel"

Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets.Add
xlSheet.Name = ActiveProject.Name

'count columns needed
ColumnCount = 0
For Each t In ActiveProject.Tasks
    If Not t Is Nothing Then
        If t.OutlineLevel > ColumnCount Then
            ColumnCount = t.OutlineLevel
        End If
    End If
Next t

'Set Range to write to first cell
Set xlRow = xlApp.ActiveCell
'xlRow = "Filename: " & ActiveProject.Name <---I don't want this info on the 
sheet.
'dwn 1
'xlRow = "OutlineLevel"
'dwn 1

'label Columns
For Columns = 1 To (ColumnCount + 1)
    Set xlCol = xlRow.Offset(0, Columns - 1)
    xlCol = Columns - 1
Next Columns
rgt 2
xlCol = "#"
rgt 1
xlCol = "Duration"
rgt 1
xlCol = "Start"
rgt 1
xlCol = "Finish"
rgt 1
xlCol = "Predecessors"
rgt 1
xlCol = "Business Function"
rgt 1
xlCol = "Resource"
rgt -7 - ColumnCount 'Dependant on column count
xlCol = "Task Name"  <--- Added to complete header row.
dwn 1
Tcount = 0
Acount = 0
For Each t In ActiveProject.Tasks
    If Not t Is Nothing Then
        'dwn 1 <--- Did not match how I want it formatted
        Set xlCol = xlRow.Offset(0, t.OutlineLevel)
        xlCol = t.Name
            If t.Summary Then
                xlCol.Font.Bold = True
                dwn 1
            End If
        For Each Asgn In t.Assignments
            'dwn 1 <--- Did not match how I want it formatted.
            Set xlCol = xlRow.Offset(0, Columns)
            If Acount = 0 Then
                xlCol = Asgn.TaskID
                rgt 1
                xlCol = (Asgn.Work / 480) & " Days"
                rgt 1
                xlCol = Asgn.Start
                rgt 1
                xlCol = Asgn.Finish
                rgt 1
                xlCol = t.Predecessors
                rgt 1
                xlCol = t.Text1
                rgt 1
            Else  <--- For loop added in to format where more than one 
resource is against a task
                rgt 6
            End If
            xlCol = Asgn.ResourceName
            dwn 1
            Acount = Acount + 1
        Next Asgn
        Tcount = Tcount + 1
        Acount = 0
    End If
Next t

'Delete first column  <----Start of my formatting routine
Excel.Range("A:A").Select  <---- Method 'Range' of object '_Global' failed
Selection.Delete Shift:=xlToLeft
'Delete first blank
Selection.Offset(0, ColumnCount).Range("A:A").Select
Selection.Delete Shift:=xlToLeft
'Format task number
Selection.Cut
Excel.Range("A:A").Select
Selection.Insert Shift:=xlToRight
Excel.Range("A:A").EntireColumn.AutoFit
Excel.Range("A:A").HorizontalAlignment = xlCenter
'Clear column numbers
Excel.Range(Cells(1, 3), Cells(1, ColumnCount + 1)).Clear
'Resizes task columns
Excel.Range(Cells(1, 2), Cells(1, ColumnCount)).ColumnWidth = 2.14
Selection.Offset(0, ColumnCount).EntireColumn.Select
Selection.EntireColumn.AutoFit
'Sort out predecessor column
Selection.Offset(0, 4).EntireColumn.Select
Selection.ColumnWidth = 13.57
Selection.HorizontalAlignment = xlLeft
'Format start and finish dates
Excel.Range(Cells(1, ColumnCount + 3), Cells(1, ColumnCount + 
4)).EntireColumn.Select
Selection.NumberFormat = "d-mmm-yy"
Selection.HorizontalAlignment = xlCenter
Selection.EntireColumn.AutoFit
'Adjust column width for last two columns
Selection.Offset(0, 3).EntireColumn.Select
Selection.EntireColumn.AutoFit
'Merges task name cells
Excel.Range(Cells(1, 2), Cells(1, ColumnCount + 1)).Select
Selection.Merge
'Makes header row bold
Rows("1:1").Select
Selection.Font.Bold = True

'AppActivate "Microsoft Project"
MsgBox ("Macro Complete with " & Tcount & " Tasks Written")
End Sub

Sorry for the length, and thanks for the help!
James

"Jack Dahlgren MVP" wrote:

> The Excel library for excel 2003 should be v11, 2007 is v12.
> 
> Like Jan said, try fully qualifying the method (ie Excel.Range instead of 
> Range).
> The other thing to look at is whether there is a sheet which is active. With 
> no active sheet the range doesn't mean anything.
> 
> -Jack Dahlgren
> 
> "James"  wrote in message 
> news:E54CEF02-ABFC-4282-9EBD-C42D2902B6FB@microsoft.com...
> > Thanks Jack, John, Gary and Jan for your feedback.
> >
> > I currently have this code added just before it kicks back to Project to
> > show the message box.
> >
> > 'Delete first column
> > Range("A:A").Select
> > Selection.Delete Shift:=xlToLeft
> >
> > which deletes the blank '0' column. It is the 'Range' line that kicks out
> > every other time it runs.
> >
> > Jack, excel is open at this  point, as your Macro has already started and
> > populated a sheet with my Project data. However, the hidden "Personal.xls" 
> > is
> > not open at this point. I originally created a Macro in Excel, but had to
> > save, close and re-open before I could use it.
> >
> > Jan, you could be right, here, and I wondered if it might be something 
> > like
> > this. But why whould it work every other time it is run? If it was this,
> > would it fail every time? I will try the change you suggest and see if the
> > issue continues.
> >
> > As to which section this should be in, I already have this same question 
> > in
> > two forums here. I put it here originally as this has originated from VBA
> > used in the desktop version of Project, not developer. I choose not to 
> > post
> > it in the Excel board originally as I felt the problem arose due to the 
> > fact
> > that the VBA coding is in MSP, and I wouldn't get the same issue if this 
> > code
> > was solely in Excel.
> >
> > One contributing factor could be that I am using Project 2007 with Office
> > 2003?
> >
> > Also, when I check the references, I see V5 of the Excel object library 
> > for
> > "Global.MPT", and V11 for my current project file. Should they both be 
> > V11?
> >
> > Thanks for your help!
> >
> > James.
> >
> > "Jack Dahlgren MVP" wrote:
> >
> >> Hmmm...
> >>
> >> Haven't looked at that code for a while, but I'm imagining that you are
> >> running this line when there is no instance of excel open.
> >> Posting the code is the only way to know what is going on here.
> >> And the others are correct that this should be in the
> >> microsoft.public.project.developer newsgroup.
> >> -Jack
> >>
> >> "James"  wrote in message
> >> news:B27CF702-94C8-4F11-8896-28DE42BE7DB8@microsoft.com...
> >> > Hi,
> >> > I'm developing some extra coding onto the end of Jack's Heirarchy macro
> >> > with
> >> > some formatting steps so that I do not have to format the spreadsheet
> >> > every
> >> > tme i run the macro.
> >> >
> >> > I have come up against a little bit of an annoyance, though, and as I'm 
> >> > no
> >> > expert, would like some help in resolving it.
> >> >
> >> > The first line of code I have added is:
> >> >
> >> > Range("A:A").Select
> >> >
> >> > The first time I run the code I get no errors. The second time I run 
> >> > the
> >> > code, I get the following error:
> >> >
> >> > Run Time Error '1004':
> >> > Method 'Range' of Object '_Global' failed
> >> >
> >> > When I debug, the first line of my code above is highlighted.
> >> >
> >> > If I end, and run a third time, it runs ok. But every alternate time I 
> >> > run
> >> > the code, I get the same error.
> >> >
> >> > I have selected the Excel object library reference, else it wouldn't 
> >> > run
> >> > at
> >> > all.
> >> >
> >> > Can anyone point me towards why I get this error?
> >> >
> >> > Thanks
> >> > James.
> >> 
>
date: Fri, 10 Oct 2008 01:55:02 -0700   author:   James

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us