|
-
Aug 26th, 2007, 01:42 AM
#1
Thread Starter
Lively Member
-
Aug 26th, 2007, 03:05 AM
#2
Re: Saving an Excel file using VB6
activeworkbook.fullname will return the complete path/filename
to delete the workbook when you are finished
vb Code:
myfile = activeworkbook.fullname 'before closing workbook
kill myfile' after closing workbook
i don't see any reason why you need to save the workbook at all
ThisWorkbook.Close SaveChanges:=False
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Aug 26th, 2007, 03:16 AM
#3
Thread Starter
Lively Member
-
Aug 26th, 2007, 03:58 AM
#4
Re: Saving an Excel file using VB6
the legend is on the worksheet not the chart sheet?
i have no idea why this would be
This example turns on the legend for Chart1 and then sets the legend font color to blue.
Charts("Chart1").HasLegend = True
Charts("Chart1").Legend.Font.ColorIndex = 5
Remarks
The chart legend isn’t visible unless the HasLegend property is True. If this property is False, properties and methods of the Legend object will fail.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Aug 26th, 2007, 04:11 AM
#5
Thread Starter
Lively Member
Re: Saving an Excel file using VB6
I did add the part you advised and changed the selection to ChartArea instead of PlotArea, but no success yet.
Code:
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "All Cases"
.HasLegend = True
.Legend.Font.ColorIndex = 5
End With
Code:
.ActiveChart.ChartArea.Select
-
Aug 26th, 2007, 04:19 AM
#6
Thread Starter
Lively Member
-
Aug 26th, 2007, 04:48 AM
#7
Frenzied Member
Re: [RESOLVED] Saving an Excel file using VB6
Hey NightHeart, something I want to say about your code.
You have used Active Chart and Workbook in your code. I also used this before Si_the_Geek pointed out its not good to use them. See the following
http://www.vbforums.com/showthread.php?t=391665
http://www.vbforums.com/showthread.php?t=485465 Post # 5
So I suggest you change your code to avoid them
-
Aug 26th, 2007, 04:52 AM
#8
Re: [RESOLVED] Saving an Excel file using VB6
You have used Active Chart and Workbook in your code. I also used this before Si_the_Geek pointed out its not good to use them. See the following
i totally agree should not use select, selection,active or activate, unless there is a specific reason for doing so
address all ranges and sheets by name or setting them as ranges or worksheets as appropriate
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Aug 26th, 2007, 06:05 AM
#9
Thread Starter
Lively Member
Re: [RESOLVED] Saving an Excel file using VB6
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|