RandomGerman
03-21-2017, 12:10 PM
Hi all,
I have a problem, which is really confusing me, as the code is working well on one machine and not working on a second. At last, I don't really think it is a problem of the code, but we'll see. Maybe our gurus Show me I'm wrong - wouldn't be the first time. ;)
What the macro should do: Open a hidden text file (.txt) - read the path written inside this text file - follow that path - open a presentation hidden at the end of this path - copy slide 4 from this hidden presentation - close it - close the text file - paste slide 4 into the active presentation.
Sub PasteInSlide4()
Dim src As Presentation
Dim strpath1 As String
Dim strpath2 As String
Dim TextFile As Integer
Dim FilePath As String
Dim FileContent As String
strpath1 = Environ("USERPROFILE") & "\AppData\Roaming\Microsoft\AddIns\"
FilePath = strpath1 & "System_File_Location.txt"
TextFile = FreeFile
Open FilePath For Input As TextFile
FileContent = Input(LOF(TextFile), TextFile)
strpath2 = FileContent
Set src = Application.Presentations.Open(strpath2)
src.Slides(4).Copy
src.Close
Close TextFile
ActivePresentation.Slides.Paste (ActiveWindow.View.Slide.SlideIndex)
ActiveWindow.View.GotoSlide (ActiveWindow.View.Slide.SlideIndex - 1)
End Sub
It works fine on one machine and it does not on another machine. It stops working quite early on the second machine, leaving the run time error "PowerPoint could not open the file". At first, I didn't know, if "the file" is the txt or the hidden PowerPoint file (src in the code). I tested opening the hidden PowerPoint file directly, leaving out the txt, which worked, so the problem seems to be the text file. Now the confusing matter: Both machines run Windows 7, both machines have PPT2007, the name of the txt-file is the same, the path/location is the same, and admin rights and the security settings of both machines are the same, too.
Any ideas, what else I could check? There must be a difference somewhere on the two machines making one able to open the txt out of the macro and the other one not. But where? What else should I compare?
I'm happy about any suggestion.
Thank you
RG
I have a problem, which is really confusing me, as the code is working well on one machine and not working on a second. At last, I don't really think it is a problem of the code, but we'll see. Maybe our gurus Show me I'm wrong - wouldn't be the first time. ;)
What the macro should do: Open a hidden text file (.txt) - read the path written inside this text file - follow that path - open a presentation hidden at the end of this path - copy slide 4 from this hidden presentation - close it - close the text file - paste slide 4 into the active presentation.
Sub PasteInSlide4()
Dim src As Presentation
Dim strpath1 As String
Dim strpath2 As String
Dim TextFile As Integer
Dim FilePath As String
Dim FileContent As String
strpath1 = Environ("USERPROFILE") & "\AppData\Roaming\Microsoft\AddIns\"
FilePath = strpath1 & "System_File_Location.txt"
TextFile = FreeFile
Open FilePath For Input As TextFile
FileContent = Input(LOF(TextFile), TextFile)
strpath2 = FileContent
Set src = Application.Presentations.Open(strpath2)
src.Slides(4).Copy
src.Close
Close TextFile
ActivePresentation.Slides.Paste (ActiveWindow.View.Slide.SlideIndex)
ActiveWindow.View.GotoSlide (ActiveWindow.View.Slide.SlideIndex - 1)
End Sub
It works fine on one machine and it does not on another machine. It stops working quite early on the second machine, leaving the run time error "PowerPoint could not open the file". At first, I didn't know, if "the file" is the txt or the hidden PowerPoint file (src in the code). I tested opening the hidden PowerPoint file directly, leaving out the txt, which worked, so the problem seems to be the text file. Now the confusing matter: Both machines run Windows 7, both machines have PPT2007, the name of the txt-file is the same, the path/location is the same, and admin rights and the security settings of both machines are the same, too.
Any ideas, what else I could check? There must be a difference somewhere on the two machines making one able to open the txt out of the macro and the other one not. But where? What else should I compare?
I'm happy about any suggestion.
Thank you
RG