Linking Drawing Template to other document types such as Word & Excel.

Linking Drawing Template to other document types such as Word & Excel.

patrickJ7ELM
Contributor Contributor
871 Views
11 Replies
Message 1 of 12

Linking Drawing Template to other document types such as Word & Excel.

patrickJ7ELM
Contributor
Contributor

I'm wondering if it's possible to pull text/data from other documents and into Drawing Templates.

 

Example:

I have a drawing for a pipe and i want to pull data from a WPS (Welding procedure Specification). Lets say this document gets created by a different person but always in the same path as the output drawing. is it possible to create a dedicated field in the WPS, which again can be pulled into the dwg?

 

I would like it to show as source in "Format text" dialog.

patrickJ7ELM_0-1674216903998.png

 

i have no clue on where to begin on this and i would appreciate any inputs 🙂

 

 

0 Likes
Accepted solutions (2)
872 Views
11 Replies
Replies (11)
Message 2 of 12

patrickJ7ELM
Contributor
Contributor

Update.

 

I'm able to extract information to a custom Iproperty and then use it on the sheet. the text does not display for some reason. and im not sure how i will make the path change for different documents. 

 

GoExcel.Open("C:\Users\Patrick\OneDrive - Rørtek As\Desktop\TEST-WPS.xlsx", "Ark1")

iProperties.Value("User Defined Properties", "Standard") = GoExcel.CellValue("A3")  

iLogicVb.UpdateWhenDone = True

patrickJ7ELM_1-1674222156732.png

The iproperties does get information from excel sheet here.

patrickJ7ELM_2-1674222221726.png

but this plot does not work. 

 

 

 

 

0 Likes
Message 3 of 12

patrickJ7ELM
Contributor
Contributor

this works now. but i need to be able to change Reference excel document.

0 Likes
Message 4 of 12

tyler.warner
Advocate
Advocate

Would it work for you to just add another custom iProperty that specifies the source?

 

For both of these examples, you would just create that additional custom iProperty called "StandardSource".

 

This example you would change the property to be the title of the source file.

StandardSource = TEST-WPS.xlsx

GoExcel.Open("C:\Users\Patrick\OneDrive - Rørtek As\Desktop\" & iProperties.Value("User Defined Properties", "StandardSource"), "Ark1")

iProperties.Value("User Defined Properties", "Standard") = GoExcel.CellValue("A3")  

iLogicVb.UpdateWhenDone = True

 

 

This example you would change the property to be the full path & title of the source file.

StandardSource = C:\Users\Patrick\OneDrive - Rørtek As\Desktop\TEST-WPS.xlsx

GoExcel.Open(iProperties.Value("User Defined Properties", "StandardSource"), "Sheet1")

iProperties.Value("User Defined Properties", "Standard") = GoExcel.CellValue("A3")  

iLogicVb.UpdateWhenDone = True
If this solved your problem or answered your question, please click ACCEPT SOLUTION.
If this helped you, please click LIKE.
0 Likes
Message 5 of 12

patrickJ7ELM
Contributor
Contributor

Thanks 

 

This is better than what i had. But i want it for look for documents in the same folder as drawings. so that as long as there is a WPS-XXX.xlsx file in that folder it will use the one that is available. i dont know what will happen if there ar two different files though. 

 

to be honest, im just experimenting and trying to find ways for improvement. if you have any other ilogic/VB tips for drafts i would much appreciate. 

 

Thanks in advance 🙂

0 Likes
Message 6 of 12

A.Acheson
Mentor
Mentor

If you supply the filename and extension then go excel will search the directory of the document  you launched the rule from. 

 

GoExcel.Open("TEST-WPS.xlsx")

 

Or alternatively use ilogic function ThisDoc.Path and filename. 

 

GoExcel.Open(ThisDoc.Path & "\TEST-WPS.xlsx)

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 7 of 12

tyler.warner
Advocate
Advocate
Accepted solution

You can try something like this that will search the folder of the current document for a file that has "WPS" & ".xlsx" & then opens that one.

 

Dim oPath As String = ThisDoc.Path & "\"
Dim oFiles As String() = System.IO.Directory.GetFiles(oPath)

For Each oFile In oFiles
	If oFile.Contains("WPS") And oFile.Contains(".xlsx")
		GoExcel.Open(oFile, "Ark1")
		iProperties.Value("User Defined Properties", "Standard") = GoExcel.CellValue("A3")  
		iLogicVb.UpdateWhenDone = True
		Exit For
	End If
Next

 

If this solved your problem or answered your question, please click ACCEPT SOLUTION.
If this helped you, please click LIKE.
0 Likes
Message 8 of 12

patrickJ7ELM
Contributor
Contributor

This is close to what i want. i am just experimenting as previously stated. but i will get a problem with multiple files named WPS.xlsx, right?

 

Thanks alot for your help 🙂

0 Likes
Message 9 of 12

tyler.warner
Advocate
Advocate

It will just go with the first file that it finds which fits the search criteria. You can add a prompt or something if you want to do a check.

If this solved your problem or answered your question, please click ACCEPT SOLUTION.
If this helped you, please click LIKE.
0 Likes
Message 10 of 12

patrickJ7ELM
Contributor
Contributor

Any suggestion to how that prompt would look? 

0 Likes
Message 11 of 12

tyler.warner
Advocate
Advocate
Accepted solution

You could do something like this with a basic message box if you want user interaction.

Dim oPath As String = ThisDoc.Path & "\"
Dim oFiles As String() = System.IO.Directory.GetFiles(oPath)

For Each oFile In oFiles
	If oFile.Contains("WPS") And oFile.Contains(".xlsx")
		Dim oResult = MessageBox.Show("Is this the correct file?" & vbNewLine & oFile, "File Selection", MessageBoxButtons.YesNo)
		If oResult = DialogResult.Yes
			GoExcel.Open(oFile, "Ark1")
			iProperties.Value("User Defined Properties", "Standard") = GoExcel.CellValue("A3")  
			iLogicVb.UpdateWhenDone = True
			Exit For
		End If
	End If
Next
If this solved your problem or answered your question, please click ACCEPT SOLUTION.
If this helped you, please click LIKE.
0 Likes
Message 12 of 12

patrickJ7ELM
Contributor
Contributor

Good job, i can see there are many possibilities to achieve my goal. 

 

thanks alot, i'll try to be more active on ilogic/vba as this is a very interesting subject.

0 Likes