Avatar billede rabitjosph Juniormester
21. januar 2009 - 07:39 Der er 8 kommentarer og
1 løsning

Åben skrivebeskyttet fil

Hej

Jeg skal åben en xls fil, når jeg åbner den spørger den om den skal åbnes som skrivebeskyttet.
Jeg ønsker ikke at åben den som skrivebeskyttet, hvad skriver jeg i makro ?

I xls filen er der slå op funktioner, det spørger den også
om.
Jeg ønsker ikke den skal opdater disse funktioner
Hvad skriver jeg i makro ?
Avatar billede martin_moth Mester
21. januar 2009 - 12:05 #1
prøv at vis den kode du allerede har
Avatar billede rabitjosph Juniormester
21. januar 2009 - 17:42 #2
Workbooks.Open Filename:= _
        "G:\2009\5 dage og grafopfølgning\5 dg opg.xls"


Kan det være noget med den xls fil at der kan sættes et flueben så den altid spørger om man vil åbne den skrivebeskyttet ?

Min makro skal altid åbne som ikke skrivebeskyttet
Avatar billede martin_moth Mester
21. januar 2009 - 18:09 #3
ret det til

Workbooks.Open "G:\2009\5 dage og grafopfølgning\5 dg opg.xls", , False

Det hele står i hjælpen i Excel :o)

Herunder kan du se hvilke parametre du også kan sætte:

expression.Open(FileName, UpdateLinks, ReadOnly, Format, Password, WriteResPassword, IgnoreReadOnlyRecommended, Origin, Delimiter, Editable, Notify, Converter, AddToMru, Local, CorruptLoad)
Avatar billede martin_moth Mester
21. januar 2009 - 18:10 #4
Sakset fra hjælpen:


Open Method
See AlsoApplies ToExampleSpecificsOpen method as it applies to the Workbooks object.

Opens a workbook.

expression.Open(FileName, UpdateLinks, ReadOnly, Format, Password, WriteResPassword, IgnoreReadOnlyRecommended, Origin, Delimiter, Editable, Notify, Converter, AddToMru, Local, CorruptLoad)
expression    Required. An expression that returns the Workbooks object.

FileName  Required String. The file name of the workbook to be opened.

UpdateLinks  Optional Variant. Specifies the way links in the file are updated. If this argument is omitted, the user is prompted to specify how links will be updated. Otherwise, this argument is one of the values listed in the following table.

Value Meaning
0 Doesn't update any references
1 Updates external references but not remote references
2 Updates remote references but not external references
3 Updates both remote and external references

If Microsoft Excel is opening a file in the WKS, WK1, or WK3 format and the UpdateLinks argument is 2, Microsoft Excel generates charts from the graphs attached to the file. If the argument is 0, no charts are created.

ReadOnly  Optional Variant. True to open the workbook in read-only mode.

Format  Optional Variant. If Microsoft Excel is opening a text file, this argument specifies the delimiter character, as shown in the following table. If this argument is omitted, the current delimiter is used.

Value Delimiter
1 Tabs
2 Commas
3 Spaces
4 Semicolons
5 Nothing
6 Custom character (see the Delimiter argument)

Password  Optional Variant. A string that contains the password required to open a protected workbook. If this argument is omitted and the workbook requires a password, the user is prompted for the password.

WriteResPassword  Optional Variant. A string that contains the password required to write to a write-reserved workbook. If this argument is omitted and the workbook requires a password, the user will be prompted for the password.

IgnoreReadOnlyRecommended  Optional Variant. True to have Microsoft Excel not display the read-only recommended message (if the workbook was saved with the Read-Only Recommended option).

Origin  Optional Variant. If the file is a text file, this argument indicates where it originated (so that code pages and Carriage Return/Line Feed (CR/LF) can be mapped correctly). Can be one of the following XlPlatform constants: xlMacintosh, xlWindows, or xlMSDOS. If this argument is omitted, the current operating system is used.

Delimiter  Optional Variant. If the file is a text file and the Format argument is 6, this argument is a string that specifies the character to be used as the delimiter. For example, use Chr(9) for tabs, use "," for commas, use ";" for semicolons, or use a custom character. Only the first character of the string is used.

Editable  Optional Variant. If the file is a Microsoft Excel 4.0 add-in, this argument is True to open the add-in so that it’s a visible window. If this argument is False or omitted, the add-in is opened as hidden, and it cannot be unhidden. This option doesn't apply to add-ins created in Microsoft Excel 5.0 or later. If the file is an Excel template, True to open the specified template for editing. False to open a new workbook based on the specified template. The default value is False.

Notify  Optional Variant. If the file cannot be opened in read/write mode, this argument is True to add the file to the file notification list. Microsoft Excel will open the file as read-only, poll the file notification list, and then notify the user when the file becomes available. If this argument is False or omitted, no notification is requested, and any attempts to open an unavailable file will fail.

Converter  Optional Variant. The index of the first file converter to try when opening the file. The specified file converter is tried first; if this converter doesn’t recognize the file, all other converters are tried. The converter index consists of the row numbers of the converters returned by the FileConverters property.

AddToMru  Optional Variant. True to add this workbook to the list of recently used files. The default value is False.

Local  Optional Variant. True saves files against the language of Microsoft Excel (including control panel settings). False (default) saves files against the language of Visual Basic for Applications (VBA) (which is typically US English unless the VBA project where Workbooks.Open is run from is an old internationalized XL5/95 VBA project).

CorruptLoad  Optional Variant. Can be one of the following constants: xlNormalLoad, xlRepairFile and xlExtractData. The Default behavior if no value is specified is usually normal but may be safe load or data recovery, if Excel has already attempted to open the file.The first attempt is normal. If Excel stops operating while opening the file the second attempt is safe load.If Excel again stops operating the next
Avatar billede rabitjosph Juniormester
21. januar 2009 - 18:26 #5
Hej Martin

Hvad er det lige jeg skal skrive ?

Ved godt der står det hele men hvis jeg ikke lige kan finde ud af det, sorry
Avatar billede martin_moth Mester
21. januar 2009 - 18:39 #6
Workbooks.Open "G:\2009\5 dage og grafopfølgning\5 dg opg.xls", , False
Avatar billede rabitjosph Juniormester
21. januar 2009 - 18:50 #7
Glemte at skrive mange tak (-:
Avatar billede rabitjosph Juniormester
25. januar 2009 - 06:23 #8
Vil du sende et svar martin
Avatar billede martin_moth Mester
25. januar 2009 - 12:11 #9
det har jeg jo gjort,og du har accepteret det
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester