fjkilken
asked on
Need to open text file for use in Excel Backstage/Ribbon component
Hi
I am looking to assign dynamic text to the label property a labelControl object in a custom Backstage/Ribbon project(in Excel), this text needs to come from an external text file.
I am looking for a method similar to the one which currently works when I want to reference an image file per below:
Sub getImage(control As IRibbonControl, index As Integer, ByRef image)
Set image = LoadPicture("c:\temp\image 1.jpg")
End Sub
The labelControl object has a callback property (getLabel), which I intend to use in order to feed the text from the external text file to it.
So something like:
Sub getExternalText(control As IRibbonControl, ByRef textfile)
Set textfile= LoadFile("c:\temp\test.tex t")
End Sub
..would be great if it worked.
Appreciate any suggestions
Thanks a lot
Fergal
I am looking to assign dynamic text to the label property a labelControl object in a custom Backstage/Ribbon project(in Excel), this text needs to come from an external text file.
I am looking for a method similar to the one which currently works when I want to reference an image file per below:
Sub getImage(control As IRibbonControl, index As Integer, ByRef image)
Set image = LoadPicture("c:\temp\image
End Sub
The labelControl object has a callback property (getLabel), which I intend to use in order to feed the text from the external text file to it.
So something like:
Sub getExternalText(control As IRibbonControl, ByRef textfile)
Set textfile= LoadFile("c:\temp\test.tex
End Sub
..would be great if it worked.
Appreciate any suggestions
Thanks a lot
Fergal
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sub importTextFile(control As IRibbonControl, ByRef labeltext)
Dim fname As String
Dim sVal As String
fname = "C:\temp\Test.txt"
labeltext = OpenTextFileToString(fname )
'Debug.Print sVal
'MsgBox sVal
End Sub
Function OpenTextFileToString(ByVal strFile As String) As String
Dim hFile As Long
hFile = FreeFile
Open strFile For Input As #hFile
OpenTextFileToString = Input$(LOF(hFile), hFile)
Close #hFile
End Function
Dim fname As String
Dim sVal As String
fname = "C:\temp\Test.txt"
labeltext = OpenTextFileToString(fname
'Debug.Print sVal
'MsgBox sVal
End Sub
Function OpenTextFileToString(ByVal
Dim hFile As Long
hFile = FreeFile
Open strFile For Input As #hFile
OpenTextFileToString = Input$(LOF(hFile), hFile)
Close #hFile
End Function
This could help
http://msdn.microsoft.com/en-us/library/vstudio/bb772088.aspx
Regards