Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General PowerPoint Questions / March 2008

Tip: Looking for answers? Try searching our database.

Importing a changing text file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Simon Keeling - 11 Mar 2008 17:56 GMT
Hi,

I have a text file which changes 6-times daily (it contains weather
data).

Is it possible to imort this text file and for it to automatically
update when I load the powerpoint presntation, pretty much link
linking to an image?

Thanks in advance,
Simon Keeling
vindys - 13 Mar 2008 12:56 GMT
I guess reading from txt file doesnt have any problem and will be getting
updated data too. Also you can use auto events to load the macro at the load
of powerpoint.

Sub ReadTextToTextFrame()
'load data to textframe of a shape
ActivePresentation.Slides(1).Shapes(1).TextFrame.TextRange.Text =
GetText("C:\\test.txt")
End Sub
'http://www.exceluser.com/explore/questions/vba_textcols.htm
Function GetText(sFile As String) As String
  Dim nSourceFile As Integer, sText As String

  ''Close any open text files
  Close

  ''Get the number of the next free text file
  nSourceFile = FreeFile

  ''Write the entire file to sText
  Open sFile For Input As #nSourceFile
  sText = Input$(LOF(1), 1)
  Close

  GetText = sText
End Function

This function will load the data from txt file to the textframe. You can
call this fuction at the start up.
http://skp.mvps.org/autoevents.htm

Another option is to create an addin which populates data from the file

> Hi,
>
[quoted text clipped - 7 lines]
> Thanks in advance,
> Simon Keeling
Steve Rindsberg - 13 Mar 2008 16:14 GMT
A couple of minor quibbles:

> Sub ReadTextToTextFrame()
> 'load data to textframe of a shape
> ActivePresentation.Slides(1).Shapes(1).TextFrame.TextRange.Text =
> GetText("C:\\test.txt")

Make that:
GetText("C:\test.txt")

One backslash instead of two

> End Sub
> 'http://www.exceluser.com/explore/questions/vba_textcols.htm
[quoted text clipped - 10 lines]
>    Open sFile For Input As #nSourceFile
>    sText = Input$(LOF(1), 1)

Just be aware that this will bite you if the text file is double-byte encoded
(ie, in Chinese/Japanese/Korean etc) or, I suspect, Unicode.

A routine that reads a line of input at a time and appends it to sText solves
that problem.  In theory it's a bit slower.  In practice, unless your files are
huge, there'll be no difference.

>    Close
>
[quoted text clipped - 18 lines]
> > Thanks in advance,
> > Simon Keeling

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ:  www.pptfaq.com
PPTools:  www.pptools.com
================================================
vindys - 13 Mar 2008 17:35 GMT
Thanks Steve

> A couple of minor quibbles:
>
[quoted text clipped - 58 lines]
> PPTools:  www.pptools.com
> ================================================

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.