Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
My Data Sources - how to refer for Mail Merge
Message
 
 
À
17/02/2006 14:04:49
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01097070
Message ID:
01097177
Vues:
15
Word Launches, opens the document, I just can not get the COPY into the MY DATA SOURCES to work.
	MESSAGEBOX("2:30 changes")

	SET SAFETY ON

	&& this does show the files in  My Data Sources
	my_directory = 'c:\documents and settings\a1bg1\my documents\MY DATA SOURCES\*.*'	
	gnDbcnumber = ADIR(gaDatabase, my_directory, 'DSH')		
	FOR nCount = 1 TO gnDbcnumber  && Loop for number of databases
	   MESSAGEBOX("file or folder - " + gaDatabase(nCount,1) +CHR(13) + ;
	     "attributes - " + gaDatabase(nCount,5)) 
	ENDFOR
	
	&& this did create the directory1.txt in My Dataq Sources	
	DIR LIKE 'c:\documents and settings\a1bg1\my documents\my data sources\*.*' to FILE 'c:\documents and settings\a1bg1\my documents\my data sources\directory1'

	&& this does not perform the copy
	lcfile='c:\documents and settings\a1bg1\my documents\aaa.doc'  && aaa.doc exists
	lcnewfile='c:\documents and settings\a1bg1\my documents\my data sources'
	COPY FILE (lcfile) TO (lcnewfile)

	** this delete works			
	DELETE FILE 'c:\docume~1\a1bg1\mydocu~1\my data SOURCES\eee.doc'   && this works

		
	goWordApp = createobject("Word.Application")
    word_directory = 'c:\'
	goWordApp.ChangeFileOpenDirectory (word_directory)	
	ctemplate_name = 'r:\templates\r08\L_iborfrm.doc'
	** this copy is the Real copy - it does not work 
	COPY FILE 'r:\templates\r08\rt_lettr.dbf' TO 'c:\documents and settings\a1bg1\my documents\\MY DATA SOURCES'

	goWordApp = createobject("Word.Application")

	** file does not exist
	my_data_source = 'c:\docume~1\a1bg1\mydocu~1\my data sources\rt_lettr.dbf'
	IF !FILE(my_data_source)
		MESSAGEBOX("File does not exist - " + ALLTRIM(my_data_source))
	endif	
	
	if file(ctemplate_name)	
		goWordApp.Visible = .T.		
		goWordApp.documents.open(ctemplate_name)
		gowordapp.Application.WindowState = 1		
		gowordapp.activewindow.windowstate = 3	&&maximized					
		if creccount != 0					&& Word give an error if you try to merge and your datasource is empty
			gowordapp.activedocument.mailmerge.destination = 0	&& to a new document	
			goWordApp.ActiveDocument.MailMerge.Execute
		endif			
	else
		goWordApp.Visible = .T.		
		gowordapp.Documents.Add
		gowordapp.Application.WindowState = 1
		gowordapp.activewindow.windowstate = 1	&&maximized					
		goWordapp.ActiveDocument.MailMerge.MainDocumentType = 0 		&& set as a mail merge form document
		goWordapp.ActiveDocument.MailMerge.OpenDataSource(cdatasource) 	&&attach the mail merge document to the datasource		
		goWordapp.Activedocument.SaveAs(ctemplate_name)
	endif	
	if gowordapp.Application.WindowState <> 1
		gowordapp.activewindow.left = 0
		gowordapp.activewindow.top = 0
	endif	
	
	wait "" timeout 10	&& give client time to click on word, so any messageboxes from realtrac will not make realtrac the active task
	
	release goWordApp
	
	return 
>Can you post your actual code?
>
>>I changed my Copy to use the full path C:\documents and settings\"+GETENV("username")+"\my documents\My Data Sources, but still I can not copy into My Data Sources. I was able in my application to do an ADIR in My Data Sources, and I was able to DELETE FILE, but the COPY FILE is still giving me "Error Attempting to Create A File." Any ideas?
>>
>>>You should be able to save as well using the full path with spaces since something like this works:
>>>
>>>lcfile = "C:\documents and settings\"+GETENV("username")+"\my documents\test.txt"
>>>lcnewfile = "C:\documents and settings\"+GETENV(username)+"\my documents\test1.txt"
>>>MODIFY COMMAND (lcfile)
>>>COPY FILE (lcfile) TO (lcnewfile)
>>>MODIFY COMMAND (lcnewfile)
>>>
>>>>Unfortunately, I do not have much access on the citrix machine. The Citrix tech and I were working together earlier today and he a DIR on my a1bg1 (username) and there was not a mydata~1 nor a 'my data sources' folder in mydocu~1. But it is possible in Citrix that it does not create it until it is needed?
>>>>
>>>>What I know is by doing SAVE AS once Word is launched. I type c:\docume~1\a1bg1\mydocu~1\my data source\test.doc or it just autocompleted for me c:\docume~1\a1bg1\mydocu~1\mydata~2\test.doc - notice the ~2.
>>>>
>>>>I did try in my application an ADIR on the c:\docume~1\a1bg1\mydocu~1\my data sources\*.*' and then looped through the array with a messagbox and did see all the files in that folder. So I can access the folder with that path (using the My Data Sources versus mydata~1)copy, I just can not copy to c:\dcoume~1\a1bg1\mydocu~1\my data sources in my application, I get a "Error attempting to create a file". But the citrix tech says that there are no special permission or access levels on that folder.
>>>>
>>>>Is the Water still Muddy?
>>>>
>>>>
>>>>>What does dir/x return in a dos window in your citrix environment? Does your path match it?
>>>>>
>>>>>
>>>>>>We are changing our application to work on Citrix, to use SQL Server, and upgrading to Word 2003. I have a line of code in our Mail Merge section to copy the Mail Merge data source to my data sources, but it is not working
>>>>>>
>>>>>>copy file 'r:\templates\r08\rt_lettr.dbf' to 'c:\docume~1\%username%\mydocu~1\mydata~1'
>>>>>>
>>>>>>This copy works on my local machine, but not on the Citrix machine. But I am not thinking it is Citrix related. I can copy to mydocu~1, just not mydata~1. What the copy does is creates a file mydata~1 in the My Documents folder.
>>>>>>
>>>>>>When I do a ADIR from the My Documents folder My Data Sources comes back as entry with ..S.D in the 5th column of the array. So it can see the folder, just can not write to it.
>>>>>>
>>>>>>Got the citrix tech to log onto the Citrix machine and when he was in DOS, he could not see the My Data Source folder from the My Documents folder. Very odd.
>>>>>>
>>>>>>Looking for any help or understanding regarding My Data Sources and how to copy a file into the folder. Is there a way that I can reference the My Data Sources without using mydata~1?
>>>>>>
>>>>>>Thanks
>>>>>>
>>>>>>Brenda
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform