Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modify Excell in FoxPro

Status
Not open for further replies.

konLao

Programmer
Mar 10, 2003
61
US
Dear All,
I'm using VFP 6.0 to modify Excel report. I modify cell merge, background color, no pattern, etc. If I save it manually, I will get what I see. If I make the application save the file. It will loose these setting. Can anyone help?

Thanks
 
konLao

Can you post the code your are using?

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike,
Here's portion of my code:

oExcel = createObject("Excel.Application") && i open existing file here

with oExcel
.Application.visible = .t. &&if you want to see what you are doing
.displayAlerts = false
.workbooks.open(myXLSFile)
.sheets("PRIT_TYIELD").select
.
.
.
With .ActiveSheet.PageSetup
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False && set black and white off
EndWith
.
.
.Range("A5:F10").Select
With .Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = True && I lost this setting
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
EndWith
.
.
With .Selection.Interior
.ColorIndex = 34 && I lost this setting
.Pattern = xlSolid && I lost this setting
.PatternColorIndex = xlAutomatic && I lost this setting
EndWith
.
.
.ActiveWorkbook.Save
endwith

Hope this not confuse you more.

Thanks,
 
konLao

Sorry, I cannot duplicate your problem, by using your code (and fixing the missing constans values), and save, and reopened and the changes are still there. Is it possible that you are loading a read-only file and since you disabling the alerts, you are missing the message? Set the alerts back on and see what you get.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Is it OK to write in VFP 'false' or 'true' instead of F or T ?
And i use values instead of eg 'xlNone' (=-4142 - these values you can find in Object Browser In VBA)

Monika from Warszawa (Poland)
(monikai@yahoo.com)
 
Monika,

Is it OK to write in VFP 'false' or 'true' instead of F or T ?

No. Those values are for VB; they won't work in VFP. The usual technique is to use #DEFINE to set FALSE equal to .F. and TRUE to .T.

On the other hand, that probably isn't the cause of KonLao's problem. If he didn't have the #DEFINEs, he would have got an error before he reached the .Save.

Mike

Mike Lewis
Edinburgh, Scotland
 
Mike,
I think the problem here is that I'm runing Visual FoxPro 6.0 on WIN XP. As you know, these two guys may not like each other. Microsoft!!!

Mgagno and Mike Lewis,
I use include file that define these variables.

I'll try to do more research on this. If I find the solution, I will post it here.

Thanks guys,

KonLao
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top