Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / June 2007

Tip: Looking for answers? Try searching our database.

Current folder

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Khalil Handal - 24 Jun 2007 15:39 GMT
I have VBA code for inserting a picture as a header with the following code:

       With ActiveSheet.PageSetup
       .CenterHeader = "&G"
       .CenterHeaderPicture.Filename =
"D:\Rosary\School_System\ROS_Logo.tif"

What changes should be done in order to use the current folder in which the
files are stored in? (If I moved the folder to another drive this will ot
work).
I tried the following in different ways, but no success!

.CenterHeaderPicture.Filename = ("ThisWorkbook.Path & "\ROS_logo.tif")
Dave Peterson - 24 Jun 2007 15:53 GMT
If the activesheet isn't a sheet in the workbook that contains the code, then
that code will fail.

Maybe you can use:

.CenterHeaderPicture.Filename = activesheet.parent.Path & "\ROS_logo.tif"

> I have VBA code for inserting a picture as a header with the following code:
>
[quoted text clipped - 9 lines]
>
> .CenterHeaderPicture.Filename = ("ThisWorkbook.Path & "\ROS_logo.tif")

Signature

Dave Peterson

Dave Peterson - 24 Jun 2007 15:57 GMT
And since you're using:

With Activesheet.pagesetup
    '...
    .CenterHeaderPicture.Filename = .parent.parent.Path & "\ROS_logo.tif"
end with

It might be more useful if you ever change from using Activesheet.

> If the activesheet isn't a sheet in the workbook that contains the code, then
> that code will fail.
[quoted text clipped - 20 lines]
>
> Dave Peterson

Signature

Dave Peterson

Khalil Handal - 24 Jun 2007 18:29 GMT
I tried both and have the error code:
Run time error 1004
Application defined or object define error

Note: The code is in a sheet named "Marks" : I have a button to press to run
the code
See the full code please:
   Sub printcert()
 Dim cell As Variant

       For Each cell In Range("certprint")
       If cell.Value = 1 Then
       Sheets("Cer_2_M").Range("a3").Value = cell.Offset(0, -90)
       Sheets("Cer_2_M").Select
       ' (ThisWorkbook.Path & "\logo_r.tif")
       With ActiveSheet.PageSetup
       .CenterHeader = "&G"
       '.CenterHeaderPicture.Filename =
"D:\Rosary\School_System\ROS_Logo.tif"
       '.CenterHeaderPicture.Filename = .Parent.Parent.Path &
"\ROS_logo.tif"
       .CenterHeaderPicture.Filename = ActiveSheet.Parent.Path &
"\ROS_logo.tif"
       .LeftHeader = "&""Arial,Bold""&11Rosary Sisters" & Chr(10) &
"&""Times New Roman,Bold""&11   Paul VI St."
       .RightHeader = "&""PT Bold Heading""&12ãÏÑÓÉ ÑÇåÈÇÊ ÇáæÑÏíÉ" &
Chr(10) & "&""Traditional Arabic,Bold""&14    Ô. ÈæáÓ ÇáÓÇÏÓ"
       .LeftFooter = "&""small fonts,Regular""&5Designed by Khalil Handal"
       End With
       ' ActiveWindow.SelectedSheets.PrintOut Copies:=1
       ActiveWindow.SelectedSheets.PrintPreview
       End If
       Next

   End Sub

> And since you're using:
>
[quoted text clipped - 34 lines]
>>
>> Dave Peterson
Dave Peterson - 24 Jun 2007 19:03 GMT
It looks to me that the code belongs in a General module--not behind the sheet
named Marks (or any sheet).

And it looks like the .centerheaderpicture lines are commented out.  So I don't
see how they could be causing the error.

What line causes the error?

> I tried both and have the error code:
> Run time error 1004
[quoted text clipped - 74 lines]
> >
> > Dave Peterson

Signature

Dave Peterson

Khalil Handal - 24 Jun 2007 19:41 GMT
Yes, the code belongs to a general module. What effect this will cause?The
button to click is in the sheet named "Marks"
I tried the following 2 lines of code one at a time and had the error:

.CenterHeaderPicture.Filename = .Parent.Parent.Path & "\ROS_logo.tif"
.CenterHeaderPicture.Filename = ActiveSheet.Parent.Path & "\ROS_logo.tif"

> It looks to me that the code belongs in a General module--not behind the
> sheet
[quoted text clipped - 92 lines]
>> >
>> > Dave Peterson
Dave Peterson - 24 Jun 2007 22:23 GMT
I'd check that folder and see if there really is a file by that name.  I'm
guessing that you mistyped its name.

> Yes, the code belongs to a general module. What effect this will cause?The
> button to click is in the sheet named "Marks"
[quoted text clipped - 103 lines]
> >
> > Dave Peterson

Signature

Dave Peterson

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.