Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 23rd, 2003, 03:40 PM
rix rix is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 26 rix User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
open word doc without read only error

hi

i have the following code

Code:
Dim wdApp As Object
Set wdApp = CreateObject("Word.Application")
wdApp.DisplayAlerts = wdAlertsNone
FileName = "C:\Log.txt"
SetAttr FileName, vbReadOnly
wdApp.Documents.Open FileName, ConfirmConversions:=False, ReadOnly:=True
wdApp.Visible = True


i still can't open the document without an error message remimding me i can only open the document in read only . . anyone else had a similar problem ??

Reply With Quote
  #2  
Old December 23rd, 2003, 07:56 PM
rix rix is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 26 rix User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
actually now i am able to open the word pad document but after i close it and return to my program i'll trigger an event which is logged and then the program crashes with -

run time error '75', Path/File Access Error

the same log i am opening is that which is written to when an event is logged. is there a way i can get round this access problem ?

Reply With Quote
  #3  
Old December 24th, 2003, 01:01 AM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,982 Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 18 h 42 m 27 sec
Reputation Power: 814
Maybe make a copy of the active log file and use the copy with your code? If you're only reading the log and not writing to it that should prevent interference from other processes.

Reply With Quote
  #4  
Old December 24th, 2003, 09:23 AM
rix rix is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 26 rix User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
yup, one filecopy statement and it all works okay

thanks and happy xmas . .

Reply With Quote
  #5  
Old December 25th, 2003, 06:50 AM
rix rix is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 26 rix User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
actually i have just realisied this only works once. After it has copied the file once any other attmpts to copy result in a path or access error. I have tried to kill the copy file so it can make a new copy each time as required but this also results in an access error.

is there a way i can override all the file protection and just kill the copy ? i cant beleive its so ardous just to open a text file as read only . . .

Reply With Quote
  #6  
Old December 25th, 2003, 07:59 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,982 Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 18 h 42 m 27 sec
Reputation Power: 814
Just delete any existing copy before making a new copy. You can simply ignore errors if there is no copy, or put in a test to see if the file exists and only delete it if it's already present.

Reply With Quote
  #7  
Old December 27th, 2003, 06:46 AM
rix rix is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 26 rix User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thx doug, i finally sorted it. i was just hoping for a faster way of doing things but this seems ok now. to kill the file okay u have to make the copy as vbnormal . .

i seen a few posts on how to do this but none with an answer so here it is for anyone looking . . .

Code:
FileCopy "c:\log.txt", "c:\logCp.txt"
Dim wdApp As Object
Set wdApp = CreateObject("Word.Application")
wdApp.DisplayAlerts = wdAlertsNone
wdApp.DisplayAlerts = False
FileName = "c:\logCp.txt"
SetAttr FileName, vbNormal
wdApp.Documents.Open FileName, ConfirmConversions:=False, ReadOnly:=False
wdApp.Visible = True
End Sub

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > open word doc without read only error


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT