The lcDocumentsPath code.

On 4/8/2021 3:44 PM, Frank Cazabon wrote:
Hey Mike, what exactly worked?

On 8 April 2021 13:34:30 GMT-04:00, "MB Software Solutions, LLC" 
<mbsoftwaresoluti...@mbsoftwaresolutions.com> wrote:
Thanks, Frank and others....that worked.


On 4/7/2021 8:52 AM, Frank Cazabon wrote:
Hi Mike,

have you worked this out yet?

On my Windows 10 PC, this line:

SYS(5) + ADDBS(GETENV("HOMEPATH")) + "Documents\"

gives me the correct path, however, maybe the sys(5) is returning the
incorrect drive? Possibly the documents folder is not in the same
folder as your default drive?

This is what I use to get the Documents folder:

#DEFINE CSIDL_PERSONAL 0x0005
LOCAL lcFolderPath, lcDocumentsPath
m.lcFolderPath = space(255)

DECLARE SHORT SHGetFolderPath IN SHFolder.dll ;
     INTEGER hwndOwner, INTEGER nFolder, INTEGER hToken, ;
     INTEGER dwFlags, STRING @pszPath

SHGetFolderPath(0, CSIDL_PERSONAL, 0, 0, @m.lcFolderPath)

m.lcDocumentsPath = Alltrim(m.lcFolderPath)

m.lcDocumentsPath = SubStr(m.lcDocumentsPath,1,
Len(m.lcDocumentsPath)
- 1)
RETURN ADDBS(m.lcDocumentsPath)

Maybe another possibility is you are trying to copy more data than
Excel can handle (I can't remember the limit from that version) or
maybe there is bad data, like a date before 1/1/1900?

But then again, those last 2 issues would probably only occur when
actually trying to open the file in Excel.

FWIW I use this code for creating Excel files these days:

         loExcel = NEWOBJECT("VFPxWorkbookXLSX",
"VFPxWorkbookXLSX.vcx")
         loExcel.SaveTabletoWorkbook(m.lcTable, m.lcXLSFile, .T., .T.)

I believe the URL for this utility is:

https://github.com/ggreen86/XLSX-Workbook-Class

Doug Hennig has a paper here that may be helpful if you want to
consider alternatives:

https://doughennig.com/papers/Pub/201607dhen.pdf

Frank.

Frank Cazabon

On 06/04/2021 1:56 pm, MB Software Solutions, LLC wrote:
I get this error when executing a COPY TO .... TYPE XL5 line in a
program designed over a decade ago: /OLE error code 0x80030003:
Unknown COM status code. /

Interesting. I remoted into the guy's computer.  He said it's a
fairly new laptop (3 months old?) and it's version is 2102 (Build
13801.20360).  I fired up vRunFox.exe and did a simple xx =
CREATEOBJECT("Excel.Application") and it worked fine.  What's
strange
to me is that the line throwing that Error 1426 is not an Excel
automation line, but the COPY TO line.  I believe the problem is the
lcFile variable.  When this code was written, Vista was the latest
operating system.  You can see how I look at the OS() to select the
proper area for My Documents.

         *** mjb 03/03/2010 - changed for Vista and beyond
         IF VAL(SUBSTR(OS(),9,1)) >= 6 THEN && Vista doesn't use My
             lcDir = SYS(5) + ADDBS(GETENV("HOMEPATH")) +
"Documents\"
         ELSE && XP and below use My
             lcDir = SYS(5) + ADDBS(GETENV("HOMEPATH")) + "My
Documents\"
         ENDIF
         lcFile = ADDBS(lcDir) + "Inventory_" + DTOC(DATE(),1)
         *** mjb 06/26/2017 - added nbrdft, ntotbf
         IF this.lShowZeroQty THEN
             COPY TO (lcFile) FIELDS ccompany, cpalletsize,
cdescription, nqtyonhand, nprice, ntotvalue, nbrdft, ntotbf FOR
this.CustomerSelected(icustid) TYPE XL5
         ELSE
             COPY TO (lcFile) FIELDS ccompany, cpalletsize,
cdescription, nqtyonhand, nprice, ntotvalue, nbrdft, ntotbf FOR
this.CustomerSelected(icustid) AND nQtyOnHand > 0 TYPE XL5
         ENDIF

So in short, I think the fact that it's Error 1426 is misleading...I
doubt it's an Excel problem at all but in fact a problem with that
lcFile actual path derived.

I think somebody recently mentioned a Doug Hennig bit of code to
look
at the user's ACTUAL path to his documents area, iirc? I'll dig for
that later after an appt but wanted to throw this out there in the
meanwhile in case others have the "I had that happen to me and this
is how I fixed it!" kind of memory recall.  ;-)

tia,
--Mike





--- StripMime Report -- processed MIME parts ---
multipart/alternative
  text/plain (text body -- kept)
  text/html
---

[excessive quoting removed by server]

_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: https://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: https://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: https://leafe.com/archives
This message: 
https://leafe.com/archives/byMID/24c11da9-5e85-14a8-3324-f21d717f2...@mbsoftwaresolutions.com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to